PHP parse_str() Function Example

PHP Script:

<?php
parse_str(“post=PHP%20parse%20str&blog=PHPTUTORS”);
echo $post;
echo “<br / >”;
echo $blog;
echo “<br / >”;
parse_str(“post=PHP%20parse%20str%20function&blog=PHPTUTORS”,$data_array);
print_r($data_array);
?>

Output:

PHP parse str
PHPTUTORS
Array ( [post] => PHP parse str function [blog] => PHPTUTORS )

Description:

parse_str() function parses a query string into variables.

parse_str function parameters:

1- String: Query string which is going to be parse into variables as shown in above script example.
2- Array: This parameter tells that query string data will be stored in an associative array as shown in above script example.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s