Is there a way to act directly on an array value returned from a function without assigning it to another variable first?

For example, if I just want the third value in a CSV record, I might like to do it like this:

$value = preg_split('/,/', "one,two,three,four")[2];

But that doesn't work. I've also tried with parentheses and/or curly braces in different positions around the preg_split().

Thank you.

--
Ghodmode

I use list and explode.

list( ,,$value ) = explode( ',','one,two,three,four' );
echo $value; //returns three
commented: exactly what I was looking for +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.