forked from monnerat/web_2025
add correction
This commit is contained in:
parent
eb2d8315f9
commit
6dd596e7b3
+35
-10
@@ -1,17 +1,19 @@
|
||||
<?php
|
||||
$clients = [
|
||||
"Luc",
|
||||
7 => "Paul",
|
||||
2 =>"Martin",
|
||||
"Arnaud"
|
||||
$clients = [
|
||||
"Luc",
|
||||
7 => "Paul",
|
||||
2 =>"Martin",
|
||||
"Arnaud"
|
||||
];
|
||||
|
||||
var_dump($clients);
|
||||
|
||||
$produits = [
|
||||
20 => "Chemise",
|
||||
3 => "Pantalon",
|
||||
10 => "Jupe",
|
||||
"Veste",
|
||||
"Blouson"
|
||||
20 => "Chemise",
|
||||
3 => "Pantalon",
|
||||
10 => "Jupe",
|
||||
"Veste",
|
||||
"Blouson"
|
||||
];
|
||||
$array = ["a","b","c"];
|
||||
$array[] = "d";
|
||||
@@ -23,4 +25,27 @@ print_r($clients);
|
||||
print_r($produits);
|
||||
print_r($array);
|
||||
echo "</pre>";
|
||||
|
||||
// Exercice 2.1
|
||||
$tab = [];
|
||||
$somme = 0;
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$somme += $i; // somme des entiers de 0 à i
|
||||
$tab[$i] = $somme; // la clé i contient cette somme
|
||||
}
|
||||
print_r($tab);
|
||||
|
||||
|
||||
// Exercice 2.2
|
||||
for ($debut = 1; $debut <= 50; $debut += 10) {
|
||||
echo "<p>";
|
||||
for ($i = $debut; $i < $debut + 10; $i++) {
|
||||
if ($i % 2 === 0) {
|
||||
echo "<strong>$i</strong> ";
|
||||
} else {
|
||||
echo "<em>$i</em> ";
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user