php-doc-en/faq/html.xml

71 lines
2.1 KiB
XML
Raw Normal View History

<?xml encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<chapter id="faq.html">
<title>PHP and HTML</title>
<titleabbrev>PHP and HTML</titleabbrev>
<para>
PHP and HTML interact a lot : PHP generate HTML, and HTML
has informations that will be sent to PHP.
</para>
<qandaset>
<qandaentry id="faq.html.arrays">
<question>
<para>How do I create arrays in a HTML &lt;form&gt;?</para>
</question>
<answer>
<para>
To get your &lt;form&gt; result sent as an array to your PHP script
you name the &lt;input&gt;, &lt;select&gt; or &lt;textarea&gt;
elements like this:
<programlisting>
&lt;input name="MyArray[]"&gt;
&lt;input name="MyArray[]"&gt;
&lt;input name="MyArray[]"&gt;
&lt;input name="MyArray[]"&gt;
</programlisting>
Notice the square brackets after the variable name, that's what
makes it an array. You can group the elements into different arrays
by assigning the same name to different elements:
<programlisting>
&lt;input name="MyArray[]"&gt;
&lt;input name="MyArray[]"&gt;
&lt;input name="MyOtherArray[]"&gt;
&lt;input name="MyOtherArray[]"&gt;
</programlisting>
This produces two arrays, MyArray and MyOtherArray, that gets sent
to the PHP script.
</para>
<para>
<emphasis>Note that you must not use indices with arrays in HTML!</emphasis>
The array gets filled in the order the elements appear in the form. For
functions you can use to process these arrays once you get them into
your scripts, please see the Arrays section in the manual.
</para>
</answer>
</qandaentry>
</qandaset>
</chapter>
<!-- 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
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
-->