php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12719 extract($array, EXTR_PREFIX_ALL, "".$int) fails
Submitted: 2001-08-13 11:48 UTC Modified: 2001-08-13 11:49 UTC
From: jpb1 at cornell dot edu Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.5 OS: Solaris 2.8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jpb1 at cornell dot edu
New email:
PHP Version: OS:

 

 [2001-08-13 11:48 UTC] jpb1 at cornell dot 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()).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-13 11:49 UTC] andrei@php.net
Prefixing it with a number would create an invalid variable name according to PHP rules, so that is why it fails.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 22:01:28 2024 UTC