如何按字符串键获取数组?

For example I need get value by string key $string:

var_dump($arr['privateContacts']); // Works

$string = 'privateContacts';
$arr[$string]; // Does not work returns NULL

Function:

function existSecureField($arr, $string, $key){ var_dump($arr[$string]); die();...

Call function:

existSecureField($secureFields, 'privateContacts', 1)

Var_dump in function existSecureField():

var_dump($arr);

array(2) { ["privatePersonal"]=> array(4) { [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) } ["privateContacts"]=> array(2) { [1]=> int(1) [2]=> int(1) } }

No, it must work. I tried this one out:

         $array = array("key" => "value");
           $k = "key";
               echo $array[$k];

Works just fine. $arr[$string]; is not a statement and it must give an error.