note 103451 added to language.types.array
| From: | admin at mid dot az | Date: | Thu, 14 Apr 2011 07:27:10 +0000 |
| Subject: | note 103451 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178818@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 69.147.83.197
Probable Submitter: 46.18.65.26
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/103451
Del: integrated -- https://master.php.net/note/delete/103451/integrated
Del: useless -- https://master.php.net/note/delete/103451/useless
Del: bad code -- https://master.php.net/note/delete/103451/bad+code
Del: spam -- https://master.php.net/note/delete/103451/spam
Del: non-english -- https://master.php.net/note/delete/103451/non-english
Del: in docs -- https://master.php.net/note/delete/103451/in+docs
Del: other reasons-- https://master.php.net/note/delete/103451
Reject -- https://master.php.net/note/reject/103451
Search -- https://master.php.net/manage/user-notes.php