php - Get first value of comma separated string
859
I'm looking for the quickest/shortest way to get the first value from comma separated string, in-line.
The best I can do is
$string = 'a,b,c,d';
echo "The first thing is " . end(array_reverse(explode(',', $string))) . ".";
but I feel that's excessive and redundant. Is there a better way?
Answer
Solution:
probably works :)
In PHP 6.0 you will be able to simply:
But this is a syntax error in 5.x and lower
Answer
Solution:
How about
Answer
Solution:
Steve
It's little bit shorter
Answer
Solution:
Answer
Solution: