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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 22 14:01:27 2019 UTC