note 20355 modified in function.parse-str by philip

From: Date: Fri, 07 Jun 2002 17:59:42 +0000
Subject: note 20355 modified in function.parse-str by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-31574@lists.php.net to get a copy of this message
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 */ [editors note: PHP converts . into _ for all variable names passed through the URL] --was-- 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 http://www.php.net/manual/en/function.parse-str.php

« previous php.notes (#31574) next »