一维数组的遍历 .
- foreach遍历数组
- <?php
- /*
- * 数组的遍历
- */
- $language = array("French",'German','Russian','Chinese','Hindi','Quechu');
- foreach ($language as $key => $value) {
- echo $key.'='.$value.'<br />';
- }
- ?>
foreach遍历数组 <?php /* * 数组的遍历 */ $language = array("French",'German','Russian','Chinese','Hindi','Quechu'); foreach ($language as $key => $value) { echo $key.'='.$value.'<br />'; } ?>
关联数组的遍历
- <?php
- /*
- * 关联数组的遍历
- */
- $userList = array('UserName'=>'Lilia','Gender'=>'female','Age'=>'23','School'=>'Peking University');
- foreach ($userList as $key => $value)
- {
- echo $key.'='.$value.'<br />';
- }
- ?>
<?php /* * 关联数组的遍历 */ $userList = array('UserName'=>'Lilia','Gender'=>'female','Age'=>'23','School'=>'Peking University'); foreach ($userList as $key => $value) { echo $key.'='.$value.'<br />'; } ?>