If I'm interested in, say, the third element of a function's return array, I'd do this:
Code: Select all
$third = explode(' ', 'blah blah blah');
print( $third[2] );
If I'm only interested in one of the elements of the array, some languages let me do this:
Code: Select all
print( explode(' ', 'blah blah blah')[2] );
I know JavaScript lets you do all kinds of crazy stuff:
Code: Select all
alert(oForm.elements[i].toFloat(3).toString().toUpper()); // not super useful, but it's the right idea
I can't get PHP to do the same thing. Is this because PHP doesn't support that kind of... "immediate evaluation," or am I simply not using the proper syntax? I've tried wrapping the function call in parentheses (a la ternary operation) and curly braces, but no success.
Also, if someone know the proper term for the functionality I'm talking about, I'd appreciate them mentioning it. I ran across it once several years ago, but I have since forgotten it and don't know where I found it.