脚本宝典收集整理的这篇文章主要介绍了php – 理解print_r输出,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
http://www.php.net/manual/en/function.print-r.php#90759归功于鲍勃
<?PHP function print_r_tree($data) { // capture the output of print_r $out = print_r($data,true); // replace something like '[element] => <newline> (' wITh <a href="javascript:toggleDisplay('...');">...</a><div id="..." style="display: none;"> $out = preg_replace('/([ \t]*)(\[[^\]]+\][ \t]*\=\>[ \t]*[a-z0-9 \t_]+)\n[ \t]*\(/iUe',"'\\1<a href=\"javascript:toggleDisplay(\''.(\$id = substr(md5(rand().'\\0'),7)).'\');\">\\2</a><div id=\"'.\$id.'\" style=\"display: none;\">'",$out); // replace ')' on its own on a new line (surrounded by whitespace is ok) with '</div> $out = preg_replace('/^\s*\)\s*$/m','</div>',$out); // print the javascript function toggleDisplay() and then the transformed output echo '<script language="Javascript">function toggleDisplay(id) { document.getElementById(id).style.display = (document.getElementById(id).style.display == "block") ? "none" : "block"; }</script>'."\n$out"; } ?>
以上是脚本宝典为你收集整理的php – 理解print_r输出全部内容,希望文章能够帮你解决php – 理解print_r输出所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。