I am newer studing php. I have asked my question in php facebook people search how to remove repeat value?
but still have some problem want to understand well.
here is the data example.
https://graph.facebook.com/search?q=tom&type=user&access_token=2227470867|2.AQD2FG3bzBMEiDV3.3600.1307905200.0-100001799728875|LowLfLcqSZ9YKujFEpIrlFNVZPQ
I want clear the repeat values. here is the answer form Tomalak Geret'kal, thanks him. It can clear the repeat name.
$names = Array();
foreach ($status_list['data'] as $data) {
$names[] = $data['name'];
}
$names = array_unique($names); // not print the same name.
foreach ($names as $name) {
echo $name;
}
for I still want to echo $id
. I tired 2 method here:
$names = Array();
foreach ($status_list['data'] as $data) {
$names[] = $data['name'];
$id[] = $data['id'];
}
$names = array_unique($names); // not print the same name.
foreach ($names as $name) {
echo $name;
echo $id; // no result
}
$names = Array();
foreach ($status_list['data'] as $data) {
$names[] = $data['name'];
}
$names = array_unique($names); // not print the same name.
foreach ($names as $name) {
echo $name;
echo $data['id']; // all the id is the last people.
}
How to do the right method? Thanks.