Array dereferencing support in PHP 5.4.0

A new nice improvement in PHP 5.4 As you can see in the news list they added array dereferencing support. What this actually means?

If a method of your class returns an array, then to use a specific element you will need another variable.

Example:

class MyClass
{
    public function giveMeArray()
    {
        return array('test'=>'myvalue');
    }
}

If you want to display ‘myvalue’, you should do something like

$myClass = new MyClass(); 
$result = $myClass->giveMeArray(); 
echo $result['test'];

In the new PHP version you can do just:

$myClass = new MyClass(); 
echo $myClass->giveMeArray()['test'];