php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16369 parse_str renames keys
Submitted: 2002-03-31 21:27 UTC Modified: 2002-03-31 21:29 UTC
From: admin at internettech dot ca Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.6 OS: win2000 adv server
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admin at internettech dot ca
New email:
PHP Version: OS:

 

 [2002-03-31 21:27 UTC] admin at internettech dot ca
When returning the results of parse_str() to an array,
the key will be renamed if it contains a period.

$str = "first=value&second[]=this+works&per.iod[]=another";
parse_str($str, $newArray);

echo $newArray;
/* prints "Array" */

echo $newArray['second']['0'];
/* prints "this works" */

echo $newArray['per.iod']['0'];
/* "Undefined index: per.iod " */

/* however...*/
echo $newArray['per_iod']['0']; /* prints "another" */

/* notice the array key has been renamed from per.iod to per_iod */

Glen

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-31 21:29 UTC] rasmus@php.net
That's on purpose since a . is not a legal character in a variable name.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC