ID: 31974 User updated by: pinhinha at gmail dot com Reported By: pinhinha at gmail dot com -Status: Open +Status: Bogus Bug Type: *Programming Data Structures Operating System: LINUX PHP Version: 5.0.3 New Comment:
ZEND PROBLEM! I FORGET TO TURN IT OF! SORRY PEOPLE! Previous Comments: ------------------------------------------------------------------------ [2005-02-15 01:42:53] pinhinha at gmail dot com Miss PHP4 version, its 4.3.10 ------------------------------------------------------------------------ [2005-02-15 01:42:47] shadda at gmail dot com Got cut off. The code also works fine in my php5.0.3. ------------------------------------------------------------------------ [2005-02-15 01:41:27] shadda at gmail dot com .... .... .... You do realise, array_combine() does exactly that, right? Not to mention that even were you using php4 there are several user comments throughought php.net that show you how to accomplish this very thing (And if I recall, There's a PEAR_COMPAT package that contains this functionality.) ------------------------------------------------------------------------ [2005-02-14 20:23:31] pinhinha at gmail dot com Description: ------------ Builds an associative array using value of previous defined vars. It works on PHP 4.0.10 It doens't work on PHP 5.0.3 If the var names don't have "_" (underscore) in the name it works on PHP4 AND PHP5. Reproduce code: --------------- function do_array() { $new_array=array(); foreach (func_get_args() as $var) { if (isset($GLOBALS[$var])) $new_array[$var]=$GLOBALS[$var]; else exit("<b>Error</b>: var '<b>$var</b>' is not set."); } return $new_array; } $domain_name = "php.net"; $visit_date = date("Y-m-d"); $array = do_array("domain_name", "visit_date"); Expected result: ---------------- $array = ("domain_name" => "php.net", "visit_date" => "2005-02-14" ); Actual result: -------------- Error: var 'domain_name' is not set. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31974&edit=1