I'm checking every possible thing in the array to see if it contains something from the data specified.
Array:
$dogs = [
"terrier" => "Terrier",
"german_shepard" => "GS",
];
Code:
if ($stmt->execute()){
while ($request = $stmt->fetch(PDO::FETCH_ASSOC)){
foreach($dogs as $x => $x_value){
if (strpos($request['Data'], $x) !== false) { // This bit!!
$dog = $x_value;
} else {
$dog = 'Unknown dog';
}
}
}
}
I then have a list, It can detect the first one in the list fine, but others it just calls 'Unknown dog' EG:
1 - Terrier
2 - Unknown Dog
3 - Unknown Dog
I want it to appear like:
1 - Terrier
2 - GS
3 - GS
I want the list to appear for each value found.