note 50832 added to function.parse-str

From: Date: Fri, 11 Mar 2005 00:26:53 +0000
Subject: note 50832 added to function.parse-str
Groups: php.notes 
Request: Send a blank email to php-notes+get-86232@lists.php.net to get a copy of this message
yet another simpler way to do the reverse this function. <?php /* BSD LINCENSE */ function build_str($query_array) { $query_string = array(); foreach ($query_array as $k => $v) { $query_string[] = $k.'='.$v; } return join('&', $query_string); } // example of use // set a query string $test_query = "a=b&c=d"; // parse a string parse_str($test_query, $query_array); //print it print_r($query_array); // test the build_str function if ( build_str($query_array) == $test_query ) { echo "It works"; } else { echo "It doesn't work"; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.parse-str.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50832 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50832&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50832&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50832&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50832&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50832&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50832&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86232) next »