note 36757 added to function.array-combine

From: Date: Tue, 21 Oct 2003 15:28:52 +0000
Subject: note 36757 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-59041@lists.php.net to get a copy of this message
If you want to use array_combine in PHP4 or so (as this seems to be only working in PHP5) try using the following function: function &array_combine ( $keys, $values ) { if ( count($keys) != count($values) ) return null; $keys = array_values($keys); $values = array_values($values); foreach( $keys as $index => $key ) $newarray[$key] = $values[$index]; return $newarray; } // Call this function like: $array = &array_combine( $keys, $values ); // And check if it ain't null (insert your own errorhandling ofc). ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36757 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36757&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36757&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59041) next »