The parse_str() function parses a query string into variables. Parses stringto_encode, as if it were the query string passed via a URL and sets variables in the current scope.
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|lef|lef|left”]
Name, Required /Optional, Value Type, Description
stringto_encode , Required, String , It is the string for which is to be parsed.
array, Optional, Array, It tells the name of array in which values will be stored.
[/table]
This will return nothing.
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, Description
PHP 7.2.0 , Usage of parse_str() without a second parameter now emits an E_DEPRECATED notice.
[/table]
<?php $strExample = "firstvar=val1&arr[]=tuts+mines&arr[]=net"; // Recommended parse_str($strExample, $output); echo "\n".$output['firstvar']; // val1 echo "\n".$output['arr'][0]; // tuts mines echo "\n".$output['arr'][1]; // net // DISCOURAGED parse_str($strExample); echo "\n".$firstvar; // value echo "\n".$arr[0]; // tuts mines echo "\n".$arr[1]; // net ?>
See below is the output of above code in Web browser.
<?php parse_str("my var=val1"); echo $my_var."\n"; parse_str("my var=val1", $output); echo $output['my_var']; // Something ?>
See below is the output of above code in Web browser.
[table caption=”” width=”100%” colwidth=”100%” colalign=”left|left”]
All variables created are already urldecoded().
We can use $_SERVER[‘QUERY_STRING’] to get the query string variables.
The magic_quotes_gpc setting affects the output of this function. as parse_str() uses the same mechanism that PHP uses to populate the $_GET and $_POST etc. variables.
Without array param variables set by this function will overwrite existing variables of the same name..
[/table]
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…