Good Morning All,
Currently, i'm trying to write a script that pulls some strings from a database that looks similar to this:
After I have all these values I explode each string at their respective delimiters ', and ||'. and use in_array() to search
I'm using forloops to do all of these manipulations but the loops seem to only find the first occurrence. For example, in the example I posted above it will find 'this', but not 'is'. And if i change the order to 'is, this' then it finds 'is' and not 'this'.
Below is the entire snippet of code.
Any help is greatly appreciated it. Thanks!
Currently, i'm trying to write a script that pulls some strings from a database that looks similar to this:
Where the number on the end is a unique ID from the database. After I pull these strings down I am trying to search through each one for another string, also pulled from a database, the string pulled from the database in this case looks like this:this||is|the||lunch||6
this||is|the||lunch||7
this, is
After I have all these values I explode each string at their respective delimiters ', and ||'. and use in_array() to search
I'm using forloops to do all of these manipulations but the loops seem to only find the first occurrence. For example, in the example I posted above it will find 'this', but not 'is'. And if i change the order to 'is, this' then it finds 'is' and not 'this'.
Below is the entire snippet of code.
Code:
$idList = explode(",", substr($idList, 1, strlen($idList)));
foreach($idList as $id){
echo "<br>";
$query55 = "SELECT * FROM table WHERE col = '$id'";
$result55 = mysql_query($query55);
while($row55 = mysql_fetch_array($result55))
{
$menu = $row55[$timeofday]; //variable previously declared
$menuItems = explode("||", $menu); //this||is||lunch||$id
echo '<br>';
foreach($favorites as $fav) //this,is
{
echo '<br>';
echo 'Searching For '. $fav;
//All variations of string
$firstcap = ucwords(strtolower($fav));
$allLower = strtolower($fav);
$allupper = strtoupper($fav);
if (in_array($firstcap, $menuItems) || in_array($allLower, $menuItems) || in_array($allupper, $menuItems))
{
///ONE OF YOUR FAVORITES WAS FOUND///
echo ' ------> found';
}
}
}
}
Any help is greatly appreciated it. Thanks!