Use of => in PHP

后端 未结 5 1498
轮回少年
轮回少年 2020-12-17 18:24

What does this mean in PHP and when is the time to use it?

 =>

Another example.

 foreach ($parent as $task_id => $tod         


        
5条回答
  •  情歌与酒
    2020-12-17 19:22

    It is used to create an associative array like this:

    $arr = array( "name" => "value" );
    

    And also in a foreach loop like this:

    foreach ($arr as $name => $value) {
        echo "My $name is $value";
    }
    

提交回复
热议问题