Hi I have a database with a table called 'vehicles' . In one of the field called 'v'. I have info stored like '1:4:7:9' etc
Each value represents a different vehicle.
If a user searches for say '1' how can i loop through the 1:4:7:9 to see if there is a match? I have one way but its too long and clumsy.
Any help greatly appreciated.
Jules
$v = "1:2:9:4:5:8:";
$a = explode(':', $v); $b = "9"; //$a = array("1", "2", "3", "4", "5", "6", "7", "8"); echo $a;
if (in_array($b, $a)) {
echo "<br>Vehicle '$b' is in the array \$a<br>";
} else {
echo "NO vehicle matches";
}
A better solution would be to properly normalise the data so that the database system can properly search it.