note 60774 deleted from function.array-merge by levim

From: Date: Mon, 24 Feb 2014 22:55:00 +0000
Subject: note 60774 deleted from function.array-merge by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198682@lists.php.net to get a copy of this message
Note Submitter: j_oaquimsilva at yahoo dot com dot br ---- 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); } ?>

« previous php.notes (#198682) next »