I am working on an API integration. Now I have a problem. First I am trying to show all specific city hotels, which city is having in my database. First FOREACH worked as well its search hotel by my database city, but on Second FOREACH I am trying to show First FOREACH city hotels show only match hotel which hotels matches from database and its not worked.
My Task is: 1st search by city which city have on my database and 2nd time search in 1st time hotel and showed hotel only match my database hotel.
1st foreach:
if($RowCount>0){
foreach($Results as $Result){
foreach($api_array as &$value){
if($Result['county'] == $value['address']['city']){
$final_array[] = $value;
}
}
}
}
2nd foreach:
foreach($final_array as &$display){
var_dump($display);
if($Result['hotel'] == $display['property_name']){
$final_array2[] = $display;
}
}
full code:
foreach($array as $api_array){
$final_array = array();
$Results = $wpdb->get_results( "select * FROM hotels where county = '$countyname'",ARRAY_A );
$RowCount = $wpdb->num_rows;
if($RowCount>0){
foreach($Results as $Result){
foreach($api_array as &$value){
if($Result['county'] == $value['address']['city']){
$final_array[] = $value;
}
}
}
}
foreach($final_array as &$display){
if($Result['hotel'] == $display['property_name']){
$final_array2[] = $display;
}
}
}