一维数组的遍历 .

  1. foreach遍历数组  
  2. <?php  
  3. /* 
  4.  * 数组的遍历 
  5.  */  
  6.     $language = array("French",'German','Russian','Chinese','Hindi','Quechu');  
  7.     foreach ($language as $key => $value) {  
  8.         echo $key.'='.$value.'<br />';  
  9.     }  
  10. ?>  
foreach遍历数组
<?php
/*
 * 数组的遍历
 */
    $language = array("French",'German','Russian','Chinese','Hindi','Quechu');
    foreach ($language as $key => $value) {
        echo $key.'='.$value.'<br />';
    }
?>

 

关联数组的遍历

 

  1. <?php  
  2.     /* 
  3.      * 关联数组的遍历 
  4.      */  
  5.      $userList = array('UserName'=>'Lilia','Gender'=>'female','Age'=>'23','School'=>'Peking University');  
  6.      foreach ($userList as $key => $value)   
  7.     {  
  8.        echo $key.'='.$value.'<br />';  
  9.      }  
  10. ?>  
<?php
    /*
     * 关联数组的遍历
     */
     $userList = array('UserName'=>'Lilia','Gender'=>'female','Age'=>'23','School'=>'Peking University');
     foreach ($userList as $key => $value) 
    {
       echo $key.'='.$value.'<br />';
     }
?>


 

 

 

 

 

主题推荐
遍历 class as php pre
猜你在找
PHP SPL
php数组
PHP SPL笔记
算法设计手册第2版读书笔记 Springer - The Algorithm Design Manual 2ed Steven SSkiena 2008
PHP SPL笔记
JNI_编程技术__网文整理中
PHP经典算法
posted @ 2014-12-11 17:38  fleam  阅读(666)  评论(0编辑  收藏  举报