Hello,
I am currently attempting to feed a text file into an array, split() on ':' and then list ONLY the values of the keys with a particular name. example:
(TEXTFILE.txt)
a:string one
a:string two
b:string three
b:string four
(SCRIPT.php)
?>
$text = file("TEXTFILE.txt");
foreach($text as $key1 => $val1) {
list($key, $value) = split(':',$val1);
$assoc_text[$key] = $value;
if ($key == "a"){
$msg .= "<h2>$value</h2>;
} else {
$msg = "foobar";
}
}
echo $msg;
?>
my outoput is always foobar.
Is this clear enough? Is there another/better way I can do this?
I am very new to php and would appreciate help.
Thanks,
Christopher