How to call a function?

There is a function that returns an array. How can you access its elements? For example:

function get_array(){
return $arr;

If you try echo get_array()[0];, PHPwill give an error.

Answer 1, authority 100%

And if you use such a crutch :)))

class A{
        public $data=array();
        function __construct($data){
function returnArray($data){
     $a=new A($data);
     return $a;
print_r(returnArray(array('msg'=>'Hello World'))->data['msg']);

Answer 2, authority 50%

$a = get_array();

Php is not javascript for you. =)

P.S. And in javascript – get_array()[0];.