Use of => in PHP

后端 未结 5 1491
轮回少年
轮回少年 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:26

    => is the array association operator, similar to the = assignment operator.

    It is used mainly in array declarations of the form $arr = array( $key=>$value) which is equivalent to $arr[$key] = $value, and of course, in the foreach control structure to assign values to key and value loop variables.

提交回复
热议问题