Array Dereferencing is really very good feature added in PHP 5.4. With this you can directly access an array object directly of a method a functions.
Now we can say that no more temporary variables in php now. This is becasue earlier we must have to take array in one variable then we can make further process on that array. Have a look at below example for what we were doing before PHP 5.4.
// now we want to get second element
$tmp = explode(" ",$string);
echo $tmp[1]; // Expert
Now have a look at code block for how we can achieve this without temporary varibale:
// now we want to get second element
echo explode(" ",$string)[1]; // Expert
Isn’t it really helpful??
No more temporary variables with arrays now!!!
Now have a look at be other benefetits of Array Dereferencing in PHP 5.4
As as above code you can deal with functions call also.
{
return array("Hello","Expert","Developer");
}
// Now to get "Expert"
echo return_array()[1]; // Expert
For full list of Features included in PHP 5.4, have a look at this article.