I had already guessed that simply using the IF (or switch) function within a foreach statement wouldn't work, but I don't know any alternatives. Here is what I want to do:
I have a text files which are used as arrays (they contain two values per line...let's say logins and passwords for the sake of explaining this). Since I call upon different arrays, I want my script to look up the requested array and associate a called value (i.e: login) with it's match (i.e: password). To do this, I figured I would have an if (or Switch) expression dynamicaly generated by the chosen array. Here is what it looks like, logicaly:
$array=file("file1.txt");
foreach ($array as $line)
if (ereg("([\t])\t+([\t])$", trim($line), $reOut)) {
if ($page = $reOut[2]){
$password = $reOut[1];
}
}
If the above intention is clear, can anyone help me find a working version of the above?
Thanks
(please note that this has nothing to do with logins and passwords, it was just for the sake of an example)