forked from monnerat/web_2025
a4580652f8
# Correction pour les TP1 TP2 et TP3 Je n'ai pas testé la connexion à la DB pour le moment car je ne peux pas me co sur https://dwarves.iut-fbleau.fr/phpmyadmin Co-authored-by: JARNOUEN DE VILLARTAY Ulysse (SAFRAN AIRCRAFT ENGINES) <ulysse.jarnouen-de-villartay@safrangroup.com> Reviewed-on: monnerat/web_2025#2
52 lines
848 B
PHP
52 lines
848 B
PHP
<?php
|
|
$clients = [
|
|
"Luc",
|
|
7 => "Paul",
|
|
2 =>"Martin",
|
|
"Arnaud"
|
|
];
|
|
|
|
var_dump($clients);
|
|
|
|
$produits = [
|
|
20 => "Chemise",
|
|
3 => "Pantalon",
|
|
10 => "Jupe",
|
|
"Veste",
|
|
"Blouson"
|
|
];
|
|
$array = ["a","b","c"];
|
|
$array[] = "d";
|
|
$array[10] = "j";
|
|
unset($array[2]);
|
|
|
|
echo "<pre>";
|
|
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>";
|
|
}
|
|
?>
|