Bug #12719 Updated: extract($array, EXTR_PREFIX_ALL, "".$int) fails
| From: | andrei@php.net | Date: | Mon, 13 Aug 2001 15:49:30 +0000 |
| Subject: | Bug #12719 Updated: extract($array, EXTR_PREFIX_ALL, "".$int) fails | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-63092@lists.php.net to get a copy of this message | ||
ID: 12719
Updated by: andrei
Reported By: jpb1@cornell.edu
Old Status: Open
Status: Closed
Bug Type: Arrays related
Operating System: Solaris 2.8
PHP Version: 4.0.5
New Comment:
Prefixing it with a number would create an invalid variable name according to PHP rules, so that is
why it fails.
Previous Comments:
------------------------------------------------------------------------
[2001-08-13 11:48:00] jpb1@cornell.edu
Under PHP 3.0.16, I could use the extract function to append extract variables from an array and
attach a prefix to each one. Often, this was a number. I could do it because "".$int made
the integer $int into a string. However, under PHP 4.0.5, the same operation returns 0, even if I
use settype to make $int into a string beforehand. The only solution I can find is to use something
like:
extract($array, EXTR_PREFIX_ALL, "x".$int)
instead of
extract($array, EXTR_PREFIX_ALL, "".$int)
(In all of my examples, $array is the product of mysql_fetch_assoc()).
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12719&edit=1