1
0
Fork 0
This commit is contained in:
Chenx221 2024-01-10 13:27:26 +08:00
parent e368f5ace3
commit 9b8c18b564
4 changed files with 119 additions and 1 deletions

View File

@ -1 +1,17 @@
<?php
$arr1 = array(1,2,3);
foreach ($arr1 as $item){
echo $item.'<br>';
}
echo '##########<br>';
$arr2 = array(
array(1,2,3),
array(4,5,6),
array(7,8,9)
);
foreach ($arr2 as $items){
foreach ($items as $item){
echo $item.' ';
}
echo '<br>';
}

View File

@ -1 +1,28 @@
<?php
<!--这里并没有使用到list()和each()-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图书信息</title>
</head>
<body>
<table>
<tr>
<th>图书名</th>
<th>作者</th>
</tr>
<?php
$book_data_array = array(
"PHP程序设计" => "张三",
"Java程序设计" => "李四",
"C++程序设计" => "王五",
"Python程序设计" => "赵六"
);
foreach ($book_data_array as $bookname => $author) {
echo "<tr><td>$bookname</td><td>$author</td></tr>";
}
?>
</table>
</body>

View File

@ -1 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图书信息</title>
</head>
<body>
<form action="#" method="post">
<table>
<tr>
<td>
<label for="question1">题目:</label>
</td>
<td>
<textarea name="question" id="question1"></textarea>
</td>
</tr>
<tr>
<td>
<label for="options1">选项:</label>
<!-- 请使用*进行分割-->
</td>
<td>
<textarea name="options" id="options1"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
<?php
if (isset($_POST['question']) && isset($_POST['options'])){
$ques = trim($_POST['question']);
$opts = explode('*',trim($_POST['options']));
echo "<table><tr><td>$ques</td></tr><tr><td>";
foreach ($opts as $opt){
echo '<input type="checkbox">'.$opt.' ';
}
echo "</td></tr></table>";
}
?>
</body>

View File

@ -1 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>数组升序排序</title>
</head>
<body>
<form action="#" method="post">
<table>
<tr>
<td>
<label for="input1">需要排序的数组(使用,隔开):</label>
</td>
<td>
<textarea name="input" id="input1"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
<?php
if (isset($_POST['input'])){
$inputs = explode(',',trim($_POST['input']));
sort($inputs);
print_r($inputs);
}
?>
</body>