Home > php教程 > php手册 > PHP函数printarray()不能输出对象

PHP函数printarray()不能输出对象

WBOY
Release: 2016-06-13 11:10:50
Original
1310 people have browsed it

PHP函数printarray()缺点: 不能输出对象 print_r()可以输出对象

  1. printarray($_REQUEST);   
  2.  function printarray($strs, 
    $
    numbers = 0) {   
  3. $space = ''; //输出字符前的空格   
  4. for($i=0;$i$numbers * 2;$i++)   
  5. $space .' ';   
  6. echo 'Arraybr/>'.$space.'(br/>';   
  7. foreach ($strs as $key=> $value ) {   
  8. if (is_array ( $value )) {   
  9. $numbers ++;   
  10. echo $space. '['.$key.'] => ';   
  11. printarray($value, $numbers);   
  12. } else {   
  13. echo $space.' ['.$key.']=> '
    .$value.'
    br/>';   
  14. }   
  15. }   
  16. echo $space. ')br/>';   
  17. }  

PHP函数printarray()输出的内容如下

<ol class="dp-xml">
<li class="alt"><span><span>Array   </span></span></li>
<li><span>(   </span></li>
<li class="alt">
<span>[ECS] =</span><span class="tag">></span><span> Array   </span>
</li>
<li><span>(   </span></li>
<li class="alt">
<span>[visit_times] =</span><span class="tag">></span><span> 2   </span>
</li>
<li><span>)   </span></li>
<li class="alt">
<span>[uchome_loginuser] =</span><span class="tag">></span><span> yoyorose   </span>
</li>
<li>
<span>[rrm_cookietime] =</span><span class="tag">></span><span> 2592000   </span>
</li>
<li class="alt">
<span>[rrm_indextype] =</span><span class="tag">></span><span> classics   </span>
</li>
<li>
<span>[uchome_mytemplate] =</span><span class="tag">></span><span> blue   </span>
</li>
<li class="alt">
<span>[rrm_loginuser] =</span><span class="tag">></span><span> yoyorose   </span>
</li>
<li>
<span>[rrm_activationauth] =</span><span class="tag">></span><span> 6f474pFbxW4oV<br>/XdtU+eyoMUxpRCx6A+0GMR4SUR/8GlagURxA   </span>
</li>
<li class="alt">
<span>[ZDEDebuggerPresent] =</span><span class="tag">></span><span> </span>PHP<span>,phtml,</span>PHP<span>3   </span>
</li>
<li>
<span>[uchome_auth] =</span><span class="tag">></span><span> 821bVB9QFgrH+4uv07tQ6q<br>CRYK9OueeM/j5gqXCJfmUZh3gptW6dP3phCqPufV<br>ZnYY3qCtuW7h1vrLxEemQG   </span>
</li>
<li class="alt">
<span>[uchome_viewuids] =</span><span class="tag">></span><span> 10_1_2_4_11_8_9_7   </span>
</li>
<li>
<span>[uchome_space_top_show] =</span><span class="tag">></span><span> 1   </span>
</li>
<li class="alt">
<span>[uchome_space_top_experience] =</span><span class="tag">></span><span> 2   </span>
</li>
<li><span>)  </span></li>
</ol>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template