php - array_unique not giving the correct output -
this give results
array( [0] => 5000 [1] => 5001 [2] => 3000 [3] => 3001 [4] => 5000 )
when use array_unique same result obtained
array ( [0] => 5000 [1] => 5001 [2] => 3000 [3] => 3001 [4] => 5000 )
foreach($detail $key => $value){ array_push($zips, $value); } } array_unique($zips);
array_unique()
not work reference. means, won't modify original array, return new array respective modifications. need save output new (or same) variable:
foreach($detail $key => $value){ array_push($zips, $value); } $zips = array_unique($zips);
read more passing reference
Comments
Post a Comment