I have a MySQL table with reports. Fetching my reports is used by function:
function fillItByRoute($lat){
global $db;
$array = array(array());
$result = $db->query("SELECT * FROM reports WHERE latitude LIKE '$lat%' ORDER BY datetime_view");
while ($row = $db->fetch_array($result)){
$array[$int][1] = "Desc";
$array[$int][2] = $row['latitude'];
}
return $array;
}
which creates an multidimensional array.
- [latitudes in MySQL are stored like 25.33236645, 23.2665666 etc…]
I have a different array:
$array_lat = array(25.5,23.1,45.2);
So, I would like to know if it is possible to get through array values of $array_lat with checking the match with values from multidimensional array created by function fillItByRoute() and storing values of function fillItByRoute() in new array?
One more time, shortly:
- There are different values in $array_lat;
- I want to check function fillItByRoute() with input of $array_lat
- Results, which suit have to be stored in new array.
- The new array should be with values (using values of my $array_lat): 25.5666332, 25.511433, 23.1233, 23.11444, 23.1, 45.269…etc, could be even hundreds of items.
Is it possible to do something like that?
Thank you very much!
I think you want something like this. It iterates through your array_lat and compares it to a value from SQL. I’m not entirely sure what you want to do with the comparison but you should put it in the if statement from the second function. If you want a new array it looks like you understand how to create those but let me know if this is too ambiguous.