Table of Contents

Syntax

void parse_str(string $queryString [, array &$arr])

(PHP 4, PHP 5)

$queryString A querystring which should be parsed into variables.
$arr If provided, key-value pairs will populate this local array instead of using local variables.
RETURNS Nothing, side-effect is that local variables are created for each key-value pair.

What it Does

This function parses a string that is in the same format as a URI query string and places the key-value pairs into variables within the local scope.

Given a query string like the one below:

make=datsun&model=510&color=blue

The following variables will be created in the local scope (after calling parse_str):

$make = 'datsun'; $model = '510'; $color = 'blue';

Example

// Parse the supplied query string into the local scope
parse_str('make=datsun&model=510&color=blue');
echo 'Make: '.$make.'<br>';
echo 'Model: '.$model.'<br>';
echo 'Color: '.$color.'<br>';
 
parse_str.txt · Last modified: 2011/02/16 13:12 by orvado
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki