Possible Duplicate:
PHP syntax for dereferencing function result
Here is what I mean. Currently I have to:
$str = "foo-bar";
$foo = explode("-",$str);
$foo = $foo[0];
What I want to do is:
$str = "foo-bar";
$foo = explode("-",$str)[0];
But it's a syntax error! Is there another way to do it on one line?
EDIT: Just want to make it clear I also want to be able to do
$str = "foo-bar-baz";
$bar = explode("-",$str)[1];
aswell.