I have a problem. This code is well in php. I am trying make that WordPress environment code. What is problem on my code? I cant understand.
Thanks

PHP Code:

$final_array = array(); 
$sql="select hotel FROM hotels"; 
$result=$mysqli->query($sql);
while ($myrow = $result->fetch_array(MYSQLI_ASSOC)){
    foreach($api_array as &$value){ 
        if($myrow['hotel'] == $value['property_name']){ 
            $final_array[] = $value; 
        } 
    } 
}

echo "<pre/>";print_r($final_array);

WordPress:

foreach($array as $api_array){

        $final_array = array(); 
        $sql = $wpdb->get_results( "select hotel FROM hotels" );
        //$result=$mysqli->query($sql);
        while ($myrow = $sql(MYSQLI_ASSOC)){
            foreach($api_array as &$value){ 
                if($myrow['hotel'] == $value['property_name']){ 
                    $final_array[] = $value; 
                } 
            } 
        }

Read more here: Need wordpress environment code


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: