Voting

: four minus four?
(Example: nine)

The Note You're Voting On

Andrew dot Boag at catalyst dot net dot nz
17 years ago
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;
}
?>

<< Back to user notes page

To Top