this give results like
Array( [0] => 5000 [1] => 5001 [2] => 3000 [3] => 3001 [4] => 5000 )
When I use array_unique same result is obtained
Array ( [0] => 5000 [1] => 5001 [2] => 3000 [3] => 3001 [4] => 5000 )
foreach($detail as $key => $value){
array_push($zips, $value);
}
}
array_unique($zips);
array_unique()
does not work by reference. That means, it won't actually modify the original array, just return a new array with the respective modifications. You need to save its output to a new (or the same) variable:
foreach($detail as $key => $value){
array_push($zips, $value);
}
$zips = array_unique($zips);
Read more about Passing by Reference
不需要foreach
和array_push
,只需将其应用并保存到所需的变量$zips
:
$zips = array_unique(array_values($zips));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.