1

Possible Duplicate:
Does PHP have an equivalent to Python's list comprehension syntax?

Does PHP have any equivalent of the simple and awesome list comprehension in python? Specifically, can I do a = [x for x in xrange(1,20)] in PHP w/o annoying loops?

Community
  • 1
  • 1
Wells
  • 10,415
  • 14
  • 55
  • 85
  • 2
    Duplicate: http://stackoverflow.com/questions/1266911/does-php-have-an-equivalent-to-pythons-list-comprehension-syntax – Mahdi.Montgomery Sep 30 '10 at 19:53
  • Short answer is "no." Some things can be done easily (see my answer, see the duplicate question) others cannot. PHP isn't Python, and please don't try to force it to be something it's not! – Matthew Sep 30 '10 at 22:19

3 Answers3

2

I think this will set you free: http://code.google.com/p/php-lc/

Chris
  • 11,780
  • 13
  • 48
  • 70
0

Correct me if I'm wrong, but isn't the python 'x for x in xrange' a loop?

0
$a = range(1,19);
Matthew
  • 47,584
  • 11
  • 86
  • 98