note 53656 deleted from function.array-combine by aidan

From: Date: Wed, 03 Aug 2005 03:04:48 +0000
Subject: note 53656 deleted from function.array-combine by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-92978@lists.php.net to get a copy of this message
Note Submitter: imilanez at gmail dot com ---- Seeing as how array_combine is a PHP5 only function I came up with the following to use on PHP4. Since the restrictions for using array_combine is that both the keys array and the values array have equal amount of rows you can do this in PHP4 <?php $keys = array('yellow', 'green', 'red'); $values = array('banana', 'pear', 'cherry'); $combinedArray = array(); if(count($keys) == count($values)){ for($x=0; $x<count($keys); $x++) $combinedArray[$keys[$x]] = $values[$x]; } } ?> This returns: combinedArray['yellow'] = banana combinedArray['green'] = pear combinedArray['red'] = cherry

« previous php.notes (#92978) next »