实例
<?php $arr = ['向军','cms']; list($a,$b) = $arr; echo $a; echo '<hr>'; echo $b; echo '<hr>'; $users = ['name'=>'小黄','age'=>'30']; list('name'=>$name,'age'=>$age) = $users; echo $name; echo $age; $arr2 = ['22','小黄','xiaoxiancai.top']; list(,,$web)=$arr2; echo '<hr>'; echo $web; $users2 =[ ['name'=>'xioahuang','age'=>'20','job'=>'php'], ['name'=>'xioahan','age'=>'24','job'=>'vue'], ['name'=>'xioawei','age'=>'25','job'=>'java'], ]; while (list('name'=>$name2,'age'=>$age2,'job'=>$job)=current($users2)): echo '<hr>'; echo "name:{$name2},age:{$age2},job:{$job}"; next($users2); endwhile; echo '<hr>'; foreach($users2 as $user){ print_r($user); echo '<hr>'; }; ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例