=>是关联数组的分隔符。在该foreach循环的上下文中,它将数组的键分配给
$user,将值分配给
$pass。
例:
$user_list = array( 'dave' => 'apassword', 'steve' => 'secr3t');foreach ($user_list as $user => $pass) { echo "{$user}'s pass is: {$pass}n";}// Prints: // "dave's pass is: apassword"// "steve's pass is: secr3t"
请注意,这也可以用于数字索引数组。
例:
$foo = array('car', 'truck', 'van', 'bike', 'rickshaw');foreach ($foo as $i => $type) { echo "{$i}: {$type}n";}// prints:// 0: car// 1: truck// 2: van// 3: bike// 4: rickshaw
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)