note 82244 added to function.array-combine

From: Date: Wed, 02 Apr 2008 12:57:59 +0000
Subject: note 82244 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-137858@lists.php.net to get a copy of this message
Also, Khalys function only works if keys of both arrays are the same because array_combine ignores keys. An easy way to ignore them is by taking array_values(). Floats can be casted to strings to avoid overwriting. So, the PHP4 function could look something like this: <?php function array_combine($arr1, $arr2) { $out = array(); $arr1 = array_values($arr1); $arr2 = array_values($arr2); foreach($arr1 as $key1 => $value1) { $out[(string)$value1] = $arr2[$key1]; } return $out; } ?> ---- Server IP: 193.198.184.18 Probable Submitter: 213.147.110.246 ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- https://master.php.net/note/edit/82244 Del: integrated -- https://master.php.net/note/delete/82244/integrated Del: useless -- https://master.php.net/note/delete/82244/useless Del: bad code -- https://master.php.net/note/delete/82244/bad+code Del: spam -- https://master.php.net/note/delete/82244/spam Del: non-english -- https://master.php.net/note/delete/82244/non-english Del: in docs -- https://master.php.net/note/delete/82244/in+docs Del: other reasons-- https://master.php.net/note/delete/82244 Reject -- https://master.php.net/note/reject/82244 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137858) next »