note 54275 added to function.parse-str

From: Date: Wed, 29 Jun 2005 12:59:20 +0000
Subject: note 54275 added to function.parse-str
Groups: php.notes 
Request: Send a blank email to php-notes+get-91130@lists.php.net to get a copy of this message
As of PHP 5, you can do the exact opposite with http_build_query(). Just remember to use the optional array output parameter. This is a very useful combination if you want to re-use a search string url, but also slightly modify it: Example: <? $url1 = "action=search&interest[]=sports&interest[]=music&sort=id"; $str = parse_str($url1, $output); // Modifying criteria: $output['sort'] = "interest"; $url2 = http_build_query($output); echo "<br>url1: ".$url1; echo "<br>url2: ".$url2; ?> Results in: url1: action=search&interest[]=sports&interest[]=music&sort=id url2: action=search&interest[0]=sports&interest[1]=music&sort=interest (Array indexes are automatically created.) ---- Manual Page -- http://www.php.net/manual/en/function.parse-str.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54275 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54275&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54275&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91130) next »