dreamwest Posted July 27, 2011 Share Posted July 27, 2011 Im trying to make this array unique but its making both keys and values unique is there a way around this? $arr = array ( [funny] => 1 [space] => 1 [chimp] => 1 [funny] => 0 [lobster] => 0 ); $track = array_unique($arr); print_r($track); Basically i need the output to be: Array ( [funny] => 1 [space] => 1 [chimp] => 1 [lobster] => 0 ) Link to comment https://forums.phpfreaks.com/topic/242937-array_unique/ Share on other sites More sharing options...
WebStyles Posted July 27, 2011 Share Posted July 27, 2011 the key 'funny' exists twice, once with value 0, and once with value 1. You cannot have the same key with 2 different values. One will overwrite the other one. Link to comment https://forums.phpfreaks.com/topic/242937-array_unique/#findComment-1247822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.