php-doc-en/faq/html.xml
2001-10-14 10:41:34 +00:00

84 lines
2.3 KiB
XML
Executable file

<?xml encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<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>
<![CDATA[
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">
]]>
</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>
<![CDATA[
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyOtherArray[]">
<input name="MyOtherArray[]">
]]>
</programlisting>
This produces two arrays, MyArray and MyOtherArray, that gets sent
to the PHP script.
</para>
<para>
<note>
<para>
You need not use indices with arrays in HTML, although you can
specify number or associative indices, so you can exactly specify
what indices will contain the information provided by that
input element. If you do not specify indices, the array gets
filled in the order the elements appear in the form.
</para>
</note>
</para>
<para>
For functions you can use to process these arrays once you get
them into your scripts, please see the
<link linkend="ref.array">Arrays section</link>.
</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
-->