note 115116 added to function.array-merge

From: Date: Wed, 28 May 2014 08:26:54 +0000
Subject: note 115116 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-199639@lists.php.net to get a copy of this message
to get unique value from multi dimensional array use this instead of array_unique(), because array_unique() does not work on multidimensional: array_map("unserialize", array_unique(array_map("serialize", $array))); Hope this will help someone; Example $a=array(array('1'),array('2'),array('3'),array('4)); $b=array(array('2'),array('4'),array('6'),array('8)); $c=array_merge($a,$b); then write this line to get unique values $c=array_map("unserialize", array_unique(array_map("serialize", $c))); print_r($c); ---- Server IP: 202.5.128.4 Probable Submitter: 39.47.249.234 ---- Manual Page -- http://php.net/manual/en/function.array-merge.php Edit -- https://master.php.net/note/edit/115116 Del: integrated -- https://master.php.net/note/delete/115116/integrated Del: useless -- https://master.php.net/note/delete/115116/useless Del: bad code -- https://master.php.net/note/delete/115116/bad+code Del: spam -- https://master.php.net/note/delete/115116/spam Del: non-english -- https://master.php.net/note/delete/115116/non-english Del: in docs -- https://master.php.net/note/delete/115116/in+docs Del: other reasons-- https://master.php.net/note/delete/115116 Reject -- https://master.php.net/note/reject/115116 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199639) next »