Current Location: Home> Function Categories> parse_str

parse_str

Parse strings into multiple variables
Name:parse_str
Category:String
Programming Language:php
One-line Description:Parses the query string into the variable.

Example

Example 1

Parses query strings into variables:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token function">parse_str</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"name=Bill&age=60"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$name</span> <span class="token operator">.</span> <span class="token string double-quoted-string">"<br>"</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$age</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Try it yourself

Example 2

Store variables in an array:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token function">parse_str</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"name=Bill&age=60"</span> <span class="token punctuation">,</span> <span class="token variable">$myArray</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token function">print_r</span> <span class="token punctuation">(</span> <span class="token variable">$myArray</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Try it yourself

Similar Functions
  • Calculate the sha1 hash value of a string sha1

    sha1

    Calculatethesha1hash
  • Convert logical-Hebrew to visual-Hebrew and convert newlines hebrevc

    hebrevc

    Convertlogical-Hebre
  • Calculate the last occurrence of the specified string in the target string strrpos

    strrpos

    Calculatethelastoccu
  • Calculate the md5 hash value of a given file md5_file

    md5_file

    Calculatethemd5hashv
  • Find the first occurrence of a string strstr

    strstr

    Findthefirstoccurren
  • Convert the first letter of each word in the string to uppercase ucwords

    ucwords

    Convertthefirstlette
  • Escape characters in a string using backslashes in C style addcslashes

    addcslashes

    Escapecharactersinas
  • Setting the locale information setlocale

    setlocale

    Settingthelocaleinfo
Popular Articles