note 50832 deleted from function.parse-str by nikic

From: Date: Thu, 23 Aug 2012 11:11:07 +0000
Subject: note 50832 deleted from function.parse-str by nikic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190182@lists.php.net to get a copy of this message
Note Submitter: ---- 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"; } ?>

« previous php.notes (#190182) next »