note 106862 added to function.phpinfo

From: Date: Tue, 13 Dec 2011 14:52:40 +0000
Subject: note 106862 added to function.phpinfo
Groups: php.notes 
Request: Send a blank email to php-notes+get-185063@lists.php.net to get a copy of this message
Hi. Here my version of saving php_info into an array: <?php function phpinfo_array() { ob_start(); phpinfo(); $info_arr = array(); $info_lines = explode("\n", strip_tags(ob_get_clean(), "<tr><td><h2>")); $cat = "General"; foreach($info_lines as $line) { // new cat? preg_match("~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] : null; if(preg_match("~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) { $info_arr[$cat][$val[1]] = $val[2]; } elseif(preg_match("~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) { $info_arr[$cat][$val[1]] = array("local" => $val[2], "master" => $val[3]); } } return $info_arr; } // example: echo "<pre>".print_r(phpinfo_array(), 1)."</pre>"; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 217.87.160.112 ---- Manual Page -- http://www.php.net/manual/en/function.phpinfo.php Edit -- https://master.php.net/note/edit/106862 Del: integrated -- https://master.php.net/note/delete/106862/integrated Del: useless -- https://master.php.net/note/delete/106862/useless Del: bad code -- https://master.php.net/note/delete/106862/bad+code Del: spam -- https://master.php.net/note/delete/106862/spam Del: non-english -- https://master.php.net/note/delete/106862/non-english Del: in docs -- https://master.php.net/note/delete/106862/in+docs Del: other reasons-- https://master.php.net/note/delete/106862 Reject -- https://master.php.net/note/reject/106862 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185063) next »