note 85323 added to function.array-combine

From: Date: Tue, 26 Aug 2008 07:00:56 +0000
Subject: note 85323 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-143822@lists.php.net to get a copy of this message
// IF THEY ARE NOT OF SAME SIZE , HERE IS A SOLUTION : $abbreviations = array("AL", "AK", "AZ", "AR", "TX", "CA"); $states = array("Alabama", "Alaska", "Arizona", "Arkansas"); function combine_arr($a, $b) { $acount = count($a); $bcount = count($b); $size = ($acount > $bcount) ? $bcount : $acount; $a = array_slice($a, 0, $size); $b = array_slice($b, 0, $size); return array_combine($a, $b); } $combined = combine_arr($abbreviations, $states); print_r($combined); // Output // Array ( [AL] => Alabama [AK] => Alaska [AZ] => Arizona // [AR] => Arkansas ) ---- Server IP: 69.147.83.197 Probable Submitter: 41.233.84.51 ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- https://master.php.net/note/edit/85323 Del: integrated -- https://master.php.net/note/delete/85323/integrated Del: useless -- https://master.php.net/note/delete/85323/useless Del: bad code -- https://master.php.net/note/delete/85323/bad+code Del: spam -- https://master.php.net/note/delete/85323/spam Del: non-english -- https://master.php.net/note/delete/85323/non-english Del: in docs -- https://master.php.net/note/delete/85323/in+docs Del: other reasons-- https://master.php.net/note/delete/85323 Reject -- https://master.php.net/note/reject/85323 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143822) next »