php递归遍历多维数组的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了php递归遍历多维数组的方法。分享给大家供大家参考。具体如下:

<?php
function get_array_elems($arrResult, $where="array"){
 while(list($key,$value)=each($arrResult)){
    if (is_array($value)){
      get_array_elems($value, $where."[$key]");
    }
    else {
      for ($i=0; $i<count($value);$i++){
      echo $where."[$key]=".$value."<BR>\n";
      }
    }
 }
}
 get_array_elems($arrResult);
?>

希望本文所述对大家的php程序设计有所帮助。

相关文章

PHP 中的批处理的实现

如果 Web 应用程序中的一个特性需要超过 1 秒或 2 秒才能完成,那么应该怎么办?需要某种离线处理解决方案。学习几种对&n...

PHP中创建空文件的代码[file_put_contents vs touch]

I has passed a small test to check which function is faster to create a new file. file_put_co...

PHP文件操作实例总结

PHP文件操作实例总结

本文实例总结了PHP文件操作。分享给大家供大家参考,具体如下: 操作文件的常用方法: flie_put_contents(url,str); file_get_contents(url...

PHP文章按日期(月日)SQL归档语句

复制代码 代码如下: select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles g...

php curl 获取https请求的2种方法

今天一个同事反映,使用curl发起https请求的时候报错:“SSL certificate problem, verify that the CA cert is OK. Detail...