Difference between “as $key => $value” and “as $value” in PHP foreach

前端 未结 8 2259
梦毁少年i
梦毁少年i 2021-01-30 01:21

I have a database call and I\'m trying to figure out what the $key => $value does in a foreach loop.

The reason I ask is because both these

8条回答
  •  野性不改
    2021-01-30 02:22

    here $key will contain the $key associated with $value in $featured. The difference is that now you have that key.

    array("thekey"=>array("name"=>"joe"))
    

    here $value is

    array("name"=>"joe")
    

    $key is "thekey"

提交回复
热议问题