note 24542 deleted from ref.strings by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 15 Sep 2004 20:48:39 +0000 |
| Subject: | note 24542 deleted from ref.strings by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76793@lists.php.net to get a copy of this message | ||
Note Submitter: global2b at yahoo dot com
----
In case any of you wanted to parse a deliminated text file, I've come up with a script that may
of some use.
//I call the function and return the parsed data in a multi-D array.
function thisone() {
$info = array();
$x=file("yourData.txt");
//Here I take the first line of the data file and grab the variable names.
$names = explode('|',$x[0]);
//Once I've got the variable names I delete x[0] so that I can run through the info array with
foreach
unset($x[0]);
foreach($x as $keyx=>$valuex) {
$w = explode('|',$valuex);
foreach($w as $keyw=>$valuew) {
$info[$keyx][$names[$keyw]] = $valuew;
}
}
return $info;
}
$bin = thisone();
print_r($bin);