Rev Author Line No. Line
4985 kaklik 1 <?php phpinfo();
2  
3 #levenstein - vzdálenost řetězců
4  
5 /*
6 // Read the file, unserialize it to an array
7 $urlArray = unserialize (file_get_contents($arrayFile));
8 // Write out the serialized array back to disk
9 file_put_contents ($arrayFile, serialize($urlArray));
10 */
11  
12 function print_r_tree($data)
13 {
14 // capture the output of print_r
15 $out = print_r($data, true);
16  
17 // replace something like '[element] => <newline> (' with <a href="javascript:toggleDisplay('...');">...</a><div id="..." style="display: none;">
18 $out = preg_replace('/([ \t]*)(\[[^\]]+\][ \t]*\=\>[ \t]*[a-z0-9 \t_]+)\n[ \t]*\(/iUe',"'\\1<a href=\"javascript:toggleDisplay(\''.(\$id = substr(md5(rand().'\\0'), 0, 7)).'\');\">\\2</a><div id=\"'.\$id.'\" style=\"display: none;\">'", $out);
19  
20 // replace ')' on its own on a new line (surrounded by whitespace is ok) with '</div>
21 $out = preg_replace('/^\s*\)\s*$/m', '</div>', $out);
22  
23 // print the javascript function toggleDisplay() and then the transformed output
24 echo '<script language="Javascript">function toggleDisplay(id) { document.getElementById(id).style.display = (document.getElementById(id).style.display == "block") ? "none" : "block"; }</script>'."\n$out";
25 }
26  
27 ?>
28