PHP Learning Notes Array traversal exercises 1

Source: Internet
Author: User

Exercises One:

Set array
$attr = Array (
Array ("n001", "Han"),
Array ("n002", "Hui"),
Array ("n003", "Miao"),
Array ("n004", "Uighur"),
);

1. Require a drop-down list of styles to be displayed on the page
<?php
/*foreach ($a as $v)
{
echo "<option>{$v [0]}</option>";
}?>
</select>
<select>
<?php
foreach ($a as $v)
{
echo "<option>{$v [1]}</option>";
}*/
?>
2. Requires a Checkbox/radio list to be displayed on the page

<?php
foreach ($a as $v)
{
Echo
"<input type= ' checkbox '/>{$v [0]}",
"<input type= ' checkbox '/>{$v [1]}.<br>";
}
?>

Inserting code

1<?PHP2 $attr=Array(3 Array("N01", "Han"),4 Array("N02", "Hui"),5 Array("N03", "Miao")6 );7?>8<select>9<?PHPTen  One foreach($attr  as $a) A{Echo"<option>{$a[0]} {$a[1]} </option> "; } -?> -</select> the<br/> -  -<label> -<?PHP + foreach($attr  as $a) -{Echo"<input type=checkbox>{$a[0]} {$a[1]}. <br/> ";} +  A?> at</label>

The results displayed on the page are:

North Song Kang (Koker) 2016-06-0415:49:47

PHP Learning Notes Array traversal exercises 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.