DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
parse_str ( ) - Parses a URL encoded string into variables   Share / Like
The parse_str() string function in PHP can be used to parse a URL encoded variable string. This function can have one or two parameters fed to it. If using only one parameter(the target string), the variables will be set in the current scope. If using two parameters like we are using in our second example, the variables get parsed into an array.

1 Parameter

Learn HTML
<?php
$myString 
"var1=Blue&var2=Red";
parse_str($myString);
echo "$var1 and $var2";
?>

Develop PHP browser display window
Blue and Red


2 Parameters

Learn HTML
<?php
$myString 
"var1=Blue&var2=Red&var3=Yellow&var4=Black";
parse_str($myString$urlEncodedParse);
foreach (
$urlEncodedParse as $k => $v) {
    echo 
"$k = $v <br />";
}
?>

Develop PHP browser display window
var1 = Blue
var2 = Red
var3 = Yellow
var4 = Black

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5