我有一个工作的脚本和循环显示各种结果,但我想要chek如果结果匹配给定的变量。它的工作方式我输入它就像' 4'但如果输入$ myArray会不会出现?
代码是
$vehicle_req = "4";
echo "Vehicle required is : ".$v[$vehicle_req]."<BR><BR>";
//----- GET COMPANIES IN AREA --------
echo "Companies in the area :<BR><BR>";
$result = mysqli_query($con,"SELECT *, ( 3959 * acos( cos( radians(53.83428999999999) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(-3.0399797000000035) ) + sin( radians(53.83428999999999) ) * sin( radians( latitude ) ) ) ) AS distance FROM clients HAVING distance < 30 ORDER BY distance LIMIT 0 , 20;");
while($row = mysqli_fetch_array($result)) {
$name = $row['name'];
$id = $row['id'];
$vehicles = $row['vehicles'];
echo "<B>".$id." -</B> ".$name."<BR>".$vehicles."<BR>";
$myArray = explode(':', $vehicles);
foreach($myArray as $my_Array){
echo "<BR>".$v[$my_Array]."<BR>";
echo $my_Array."<BR>";
if($my_Array == '4')
echo "MATCH vehicle 4<BR>";
}
}