note 103451 deleted from language.types.array by danbrown

From: Date: Thu, 14 Apr 2011 15:01:36 +0000
Subject: note 103451 deleted from language.types.array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178842@lists.php.net to get a copy of this message
Note Submitter: admin at mid dot az Reason: 5 ---- I had 2 arrays. I needed to create new array which key must be equal to value first array, value must be equal to value of second array: function array_couple($arr1, $arr2){ // iterate first array foreach($arr1 as $index=>$val){ $iteratet_arr1[] = $val; } // iterate second array foreach($arr2 as $index=>$val){ $iteratet_arr2[] = $val; } // count arrays $num1 = count($arr1); $num2 = count($arr2); // check equality of arrays if($num1 == $num2){ // create new couple array for($i=0;$i<$num1;$i++){ $newarray[$iteratet_arr1[$i]] = $iteratet_arr2[$i]; } } return $newarray; }

« previous php.notes (#178842) next »