Alternatives to Pass both Key and Value By Reference:

后端 未结 2 394
一生所求
一生所求 2021-01-18 03:13

Can someone explain to me why you can\'t pass a key as reference?

Ex:

if(is_array($where)){
    foreach($where as &$key => &$value){
              


        
2条回答
  •  情歌与酒
    2021-01-18 03:36

    why is it a problem to do that? Make it a function. A function takes an input and gives an output. Your function input will be your "unsecured" array. Your output will be the result of securing the array.

    Then you just do

    $where = secureMyArray($where);
    

    That's why you have the ability to make functions...

提交回复
热议问题