You are here : phpstringparse_str

parse_str() - string

Parses str as if it were the query string
   passed via a URL and sets variables in the current scope.
Parameters :
  • str - The input string.
  • arr - If the second parameter arr is present, variables are stored in this variable as array elements instead.

  • Syntax

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


    Example

    <?php$str = "first=value&arr[]=foo+bar&arr[]=baz";parse_str($str);echo $first;  // valueecho $arr[0]; // foo barecho $arr[1]; // bazparse_str($str, $output);echo $output['first'];  // valueecho $output['arr'][0]; // foo barecho $output['arr'][1]; // baz?>


    Output / Return Value


    Limitations


    Alternatives / See Also


    Reference