send array key function and get the result

Hi there

I want to send a key of multi deminition array to a function and get the value of that key, it should be an item or and sub array. Imagine I have this function:

public function returnArray($index){

        $arr = [

            'name' => 'ali',

            'children' => [

                '1' => 'reza',

                '2' => 'hasan',

                '3' => 'farhad',

                'info' => [







        return $arr[$index];


and when I call it like this:


the result should be info from that array.

What should I do?

Thanks in advance.

I think something like that was introduced to Yii’s ArrayHelper recently…