note 41015 rejected from function.explode by victor
| From: | victor@php.net | Date: | Sat, 27 Mar 2004 20:46:55 +0000 |
| Subject: | note 41015 rejected from function.explode by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67254@lists.php.net to get a copy of this message | ||
Note Submitter:
----
I use this short script to get the values of my config.php
It returns you an array with keys like: hostname;myhost
<?
$pfad ="./";
$config = fopen($pfad."config.php","r");
while ($zeile=fgets($config)){
if (!strpos($zeile,"//") && !strpos($zeile,"---") ){
$i++;
$string = substr($zeile,1,strpos($zeile,";")-1);
$teile = explode("=",$string,2);
$value[$i]= $teile[0];
$value[$i].= ";".substr($teile[1],1,strrpos($teile[1],"'")-1);
}
}
fclose($config);
print_r($value);
?>
It may return:
Array ( [1] => host;localhost [2] => user;password [3] => db;dbname [4] => pw; [5] =>
prefix; [6] => home;index.php?action=something )