Referencing the return value of split()
| From: | David Fuchs | Date: | Fri, 10 Aug 2001 23:58:45 +0000 |
| Subject: | Referencing the return value of split() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-62230@lists.php.net to get a copy of this message | ||
Hello,
I'm trying to use the following in a piece of code, but I keep receiving parse errors:
$myVar = split(":", $myStrings)[0];
The following code works, however:
$myTempVar = split(":", $myStrings);
$myVar = $myTempVar[0];
I'd much rather execute the statement in one line, rather than two, if possible. The PHP Manual states that split() returns an array. Why can I not reference the returned array immediately? It works in Perl... =)
Thanks for any help!
-David Fuchs