Jump to: navigation, search

Php parse str

From w3cyberlearnings

Contents

PHP function parse_str

This function parses the URLS as they appear in the HTTP GET requests.

Syntax parse_str

  • $url: specifies the URL string to be parsed.
  • $array (optional): array that the parse values to be stored.
parse_str($url,$array);

Example 1

<?php
$str = "id=3002&group=323&name=Johanil";

parse_str($str);
echo $id . '<br/>';
echo $group . '<br/>';
echo $name . '<br/>';
?>

Output

3002
323
Johanil

Example 2

  • Assign the return to the $myStr array.
<?php

$str = "name=Bob&id=382";

parse_str($str, $myStr);
print_r($myStr);
?>

Output

Array ( [name] => Bob [id] => 382 )

Related Functions


Navigation
Web
SQL
MISC
References