note 38149 added to function.array-combine

From: Date: Wed, 10 Dec 2003 01:13:20 +0000
Subject: note 38149 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-61716@lists.php.net to get a copy of this message
In PHP4, the following combination of array_map() and create_function() joined together in an eval, simulates the array_combine()-function. Whether this a better or worse than the other solutions, that's up to somebody else to define. <?php eval("\$c = array (". join(', ', array_map(create_function('$a1, $a2', 'return "\"$a1\" => \"$a2\"";'), $a, $b)) . ");"); ?> Replace "\$c" with whatever you want to name the resulting array. <e>< ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38149 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38149&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38149&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61716) next »