By using the + operator, append the array elements on the right (excluding those elements that have the same key value as the array element on the left) to the left array, but the duplicate key values are not overwritten.
Cases:
<?php
$a =array ("a" => "Apple", "B" => "banana");
$b =array ("A" => "pear", "B" => "Strawberry", "C" => "cherry");
$c = $a + $b;
Var_dump ($c);
echo "<br/>";
$c = $b + $a;
echo "\ $b +\ $a result <br/>";
Var_dump ($c);
?>
The average time that a child finishes a race
Topic:
In the sports meeting, several children race the pulley, they skate 100 meters of time respectively is 10s,12s,5.7s,9s,14s
Write a program that calculates their average time and keeps the time at the back two digits of the decimal point.
test.php:
<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>
<body>
<form action= "result2.php" method= "POST" >
<input type= "text" name= "Grade"/>
<input type= "Submit" value= "Start statistics"/>
</form>
</body>
result2.php:
<?php
Receive user submissions for student results
$grades = $_request[' Grade '];
Split
$grade = Explode ("", $grades);
foreach ($grade as $k => $v) {
$allgrades + + $v;
}
echo "Average time is:". $allgrades/count ($grade);
?>
How do I turn off the notice level hint?
Add the following statement to the PHP page:
Error_reporting (e_all ^ e_notice);
Combine test.php and result2.php:
<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>
<body>
<form action= "" method= "POST" >
<input type= "text" name= "Grade" value= "<?php echo $grades?>"/>
<input type= "Submit" value= "Start statistics"/>
</form>
<?php
Error_reporting (e_all ^ e_notice);
Receive user submissions for student results
$grades =$_request[' grade '];
Split
$gr =explode ("", $grades);
foreach ($gr as $k => $v) {
$allgrades + + $v;
}
$a = $allgrades/count ($GR);
echo "Average time is:". $a; Floor as rounding function
?>
</body>
Example: PHP output multiplication Port summary table:
<?php
For ($i =1 $i <10; $i + +) {
for ($k =1; $k <= $i; $k + +) {
echo "$i * $k". = ". $i * $k." ";
}
echo "<br/>";
}
?>
The effect of the following figure: