我只想显示 usernameArray 中不存在且仅存在于 mysql 表中的用户名。换句话说,对于 mysql 表中的每个用户名,我想在 usernamesArray 中检查它,如果该数组中不存在,我只是从 mysqltable 输出该用户名?谁能告诉我如何完成这项任务。谢谢
$url = "https://api.instagram.com/v1/users/XXXX/follows?access_token=XXXX&count=-1";
$api_response = get_data(''.$url);
$record = json_decode($api_response); // JSON decode
$m = 0;
$usernamesArray = array();
foreach($record->data as $user) // each user data (JSON array) defined as $user
{
$m++;
$usernameVar = $user->username;
$usernamesArray[] = $usernameVar;
}
print_r($usernamesArray);
$sql->Query("SELECT * FROM mytable");
echo "Total:".$sql->rows;
echo "<br>";
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$id = $sql->data[0];
$username = $sql->data[1];
$website = $sql->data[2];
$profile_picture = $sql->data[3];
//now compare usernamesArray with current data in mysql table and only display
//the usernames that doesnt exist in usernamesArray?
echo("<div id='grid-cell' style='padding:5px'><a style='text-decoration:none' href='$username'><img class='photo-grid' src='$profile_picture' width=150 height=150 title='$username' /></a><div class='moreInfo2'><a style='color:#000;text-decoration:none' href='/$username' target='_blank'>$item:$username()</a></div></div>\n");
}