note 24542 added to ref.strings
| From: | global2b at yahoo dot com | Date: | Wed, 21 Aug 2002 01:25:16 +0000 |
| Subject: | note 24542 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35285@lists.php.net to get a copy of this message | ||
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);
--
http://www.php.net/manual/en/ref.strings.php
http://master.php.net/manage/user-notes.php?action=edit+24542
http://master.php.net/manage/user-notes.php?action=delete+24542
http://master.php.net/manage/user-notes.php?action=reject+24542