I feel like there is some way of doing this with a shortcut:
$date_array = explode("-", $date);
$day = $date_array[2];
Something like:
$day = explode("-", $date)[2];
Basically getting the answer and setting it to something?
Can’t remember, but aren’t there a bunch of fancy “=” things like .= concatenation. Are there other shortcuts like that? Can’t seem to find an article on Google with all the shortcuts.
I hate having to make a $date_array when all I honestly want is the $day, makes me feel like my code isn’t efficient.
EDIT: Changed the title to be more universal, can’t think of anything great.
As the new features in PHP 5.4 page says, the syntax you suggest (known as function array dereferencing) is now possible as of that version.
This will not work, however, in 5.3 or before.