note 60774 added to function.array-merge

From: Date: Mon, 16 Jan 2006 09:22:40 +0000
Subject: note 60774 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-101913@lists.php.net to get a copy of this message
I forgot to comment. This function join two arrays adding first the elements equals in the two arrays, then the values of the first array and at the end the values of the second array. <?php function array_merge_sim ($arr1, $arr2) { $i=0; $adid_arrayS = array(); foreach ($arr1 as $x) { $j=0; $nr1=count($arr1); $nr2=count($arr2); foreach ($arr2 as $z) { if($x==$z){ array_push($adid_arrayS,$z); if($nr2==($j+1)) array_pop($arr2); else array_splice($arr2, $j,-($nr2-$j-1)); if($nr1==($i+1)) array_pop($arr1); else array_splice($arr1, $i,-($nr1-$i-1)); $i--; }else $j++; } $i++; } return array_merge($adid_arrayS,$arr1,$arr2); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-merge.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60774 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60774&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60774&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101913) next »