<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 --> <refentry id="function.parse-str"> <refnamediv> <refname>parse_str</refname> <refpurpose>Parses the string into variables</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>void</type><methodname>parse_str</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter role="reference">arr</parameter></methodparam> </methodsynopsis> <para> Parses <parameter>str</parameter> as if it were the query string passed via a URL and sets variables in the current scope. If the second parameter <parameter>arr</parameter> is present, variables are stored in this variable as array elements instead. </para> <note> <para> Support for the optional second parameter was added in PHP 4.0.3. </para> </note> <note> <para> To get the current <emphasis>QUERY_STRING</emphasis>, you may use the variable <link linkend="reserved.variables.server">$_SERVER['QUERY_STRING']</link>. Also, you may want to read the section on <link linkend="language.variables.external">variables from outside of PHP</link>. </para> </note> <note> <para> The <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> setting affects the output of this function, as <function>parse_str</function> uses the same mechanism that PHP uses to populate the <literal>$_GET</literal>, <literal>$_POST</literal>, etc. variables. </para> </note> <para> <example> <title>Using <function>parse_str</function></title> <programlisting role="php"> <![CDATA[ <?php $str = "first=value&arr[]=foo+bar&arr[]=baz"; parse_str($str); echo $first; // value echo $arr[0]; // foo bar echo $arr[1]; // baz parse_str($str, $output); echo $output['first']; // value echo $output['arr'][0]; // foo bar echo $output['arr'][1]; // baz ?> ]]> </programlisting> </example> </para> <para> See also <function>parse_url</function>, <function>pathinfo</function>, <function>get_magic_quotes_gpc</function>, and <function>urldecode</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->