# [EMAIL PROTECTED] / 2007-01-29 10:12:25 -0600:
> Roman Neuhauser wrote:
> ># [EMAIL PROTECTED] / 2007-01-29 15:27:21 +0000:
> >># crash
> >>#assert(2 == returns_array()['c']);
> >
> >># still crash
> >>#assert(2 == returns_array()['c']);
> >
> >s/crash/syntax error/
>
> You can do this in Perl:
> my $c = (fn(@a))[2];
Not to mention C++, Python, or quite a few other languages.
> But in PHP, this is a syntax error:
> $c = (fn($a))[2];
Well, DUH! THat's what the OP was curious about: why is it an error?
> Also, it's not clear what the original syntax is meant to do:
> explode($needle, $array)[3]
> explode() takes a string and converts it to an array based on the
> separator expression. This might make sense:
> explode($needle, $array[3])
> where $array[3] is a string.
>
> But explode($needle, $array), it turns out, simply returns the string
> "Array".
Not at all! Watch this:
<?php
$array = 'O M F G';
$needle = ' ';
assert(array('O', 'M', 'F', 'G') == explode($needle, $array));
?>
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php