2 つの異なるシステムから作成した 2 つのアレイがあります。
URL が変更されました
左側の配列をループして、ビジネス、住所、郵便番号に一致するものを見つける必要があります。右側に一致するものがあれば、それを取得id
して左側の配列項目に追加する必要があります。
必要に応じて変更できるように、配列を構造化しています。
${'URL'} = 'http://reviewsfor.biz/api/biz/';
// Initiate the cURL request
$curl = curl_init();
$data = array(
'api_key' => REVIEWS_API_KEY,
'format' => 'json',
'act' => 'active'
);
// Set the cURL options
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_URL, ${'URL'}.'?'.http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Execute the cURL POST
$response = curl_exec($curl);
// Close the cURL connection
curl_close($curl);
$response = json_decode($response);
// Out the list of businesses into an array
${'Business List'} = $response->businesses;
${'Local Biz Array'} = array();
${'Query'} = mysql_query('SELECT * FROM `companies`.`subdomains`');
while(${'Sub Domain'} = mysql_fetch_assoc(${'Query'})){
${'Database'} = ${'Sub Domain'}['database'];
${'DB Query'} = mysql_query('SELECT * FROM `'.${'Database'}.'`.`users`');
while(${'User'} = mysql_fetch_assoc(${'DB Query'})){
if(${'User'}['company'] != ''){
${'Local Biz Array'}[] = array('business' => ${'User'}['company'], 'address' => ${'User'}['company_address'], 'zip' => ${'User'}['company_zip'], 'user_id' => ${'User'}['id']);
}
}
}
// Build an array
${'LBL Biz Array'} = array();
foreach(${'Business List'} as $item){
${'LBL Biz Array'}[] = array('business' => $item->business->business, 'address' => $item->business->address, 'zip' => $item->business->zip, 'id' => $item->business->id);
}
echo '<div id="leftCol" style="float:left;width:49%;height:500px;overflow:scroll;">';
echo '<pre>';
print_r(${'LBL Biz Array'});
echo '</pre></div>';
echo '<div id="rightCol" style="float:right;width:49%;height:500px;overflow:scroll;">';
echo '<pre>';
print_r(${'Local Biz Array'});
echo '</pre></div>';