note 77692 modified in function.phpinfo by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 00:57:01 +0000 |
| Subject: | note 77692 modified in function.phpinfo by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141873@lists.php.net to get a copy of this message | ||
One note on the above functions for cleaning up the phpinfo() HTML and throwing it into an array
data structure. In order to catch all of the info tidbits the preg_match_all has to be tweaked to
deal with 2 and 3 column tables.
I have changed the preg_match_all() here so that the last <td></td> is optional
<?php
function parsePHPConfig() {
ob_start();
phpinfo(-1);
$s = ob_get_contents();
ob_end_clean();
$a = $mtc = array();
if (preg_match_all('/<tr><td class="e">(.*?)<\/td><td
class="v">(.*?)<\/td>(:?<td
class="v">(.*?)<\/td>)?<\/tr>/',$s,$mtc,PREG_SET_ORDER))
foreach($mtc as $v){
if($v[2] == '<i>no value</i>') continue;
$a[$v[1]] = $v[2];
}
}
return $a;
}
?>
--was--
One note on the above functions for cleaning up the phpinfo() HTML and throwing it into an array
data structure. In order to catch all of the info tidbits the preg_match_all has to be tweaked to
deal with 2 and 3 column tables.
I have changed the preg_match_all() here so that the last <td></td> is optional
function parsePHPConfig() {
ob_start();
phpinfo(-1);
$s = ob_get_contents();
ob_end_clean();
$a = $mtc = array();
if (preg_match_all('/<tr><td class="e">(.*?)<\/td><td
class="v">(.*?)<\/td>(:?<td
class="v">(.*?)<\/td>)?<\/tr>/',$s,$mtc,PREG_SET_ORDER))
foreach($mtc as $v){
if($v[2] == '<i>no value</i>') continue;
$a[$v[1]] = $v[2];
}
}
return $a;
}
http://php.net/manual/en/function.phpinfo.php