I’m calling this WordPress function:
get_user_meta($user->ID, "user_address");
And it returns array, I don’t want to put this into variable but simply echo it out.
But this doesn’t work:
get_user_meta($user->ID, "user_address")[0];
Why? any way to do this as one liner?
As per function reference you have to pass third argument
true
so that it will return you single value.Dereferencing an array immediately when it is returned by a function is a relatively new feature in PHP 5.4. You are most likely using 5.3 or older, in which case you cannot immediately access an element of an array returned by a function call.
http://docs.php.net/manual/en/language.types.array.php
If it’s the first element you need: