Question 1.2 :

Exercice 2 :

"; for($i=1; $i<=10; $i++){ $j=$i*7; echo '
  • '.$j.'
  • '; } echo ""; ?>

    Exercice 3.1 :

    'z', 10=>20, 'toto'=>'titi', 'php', 'bon'=>'jour', 'nuit']; foreach ($t as $c=>$v) echo 'clé : '.$c.' et valeur : '.$v.'
    '; ?>

    Exercice 4 :

    12, 'Silvia' => 3, 'Julien' => 19, 'Lionel' => 12, 'Mario' => 12, 'Andrea' => 9, 'Gérard' => 3]; ksort($tabE1); foreach ($tabE1 as $c=>$v) echo 'étudiant : '.$c.', note : '.$v.'
    '; asort($tabE1); foreach ($tabE1 as $c=>$v) echo 'note : '.$v.'
    '; ?>

    Exercice 5 :

    [5,9,2016], "Vacances Toussaint" => [ "début" => [22,10,2016], "fin" => [30,10,2016] ], "Vacances Noël" =>[ "début" => [17,12,2016], "fin" => [2,1,2017] ], "Vacances d'hiver" =>[ "début" => [11,2,2017], "fin" => [19,2,2017] ], "Vacances de printemps" =>[ "début" => [1,4,2017], "fin" => [9,4,2017] ], "Fin des cours" => [8,7,2017] ]; function afficheTab($tab){ if (count($tab)==1){ echo $tab.'
    '; } else{ foreach ($tab as $c=>$v){ echo 'clé : '.$c.'
    '; afficheTab($v); } } } foreach ($anneeScolaire as $c=>$v){ if(count($v)==2){ $j=2; echo $c.' : '; foreach ($v as $c1=>$v1){ if($j==2) echo 'du '.implode('/',$v1); else if($j==1) echo ' au '.implode('/',$v1); $j--; } echo '
    '; } else { echo $c.' : '.implode('/',$v).'
    '; } } ?>

    Exercice 6.1 :

    'test', 0 => 'nombre' ]; if (in_array(2, $tab)) echo '

    in_array : 2 est dans le tableau

    '; if(in_array('nombre', $tab)) echo '

    in_array : nombre est dans le tableau

    '; ?> 'test', 0 => 'nombre' ]; if (array_search(2, $tab)!==false) echo '

    array_search : 2 est dans le tableau

    '; if(array_search('nombre', $tab)!==false) echo '

    array_search : nombre est dans le tableau

    '; ?>

    Exercice 7 :

    'Mehwish', 'score' => 150], ['nom' => 'Laurent', 'score' => 120], ['nom' => 'Ines', 'score' => 98], ['nom' => 'Sondes', 'score' => 153], ['nom' => 'Davide', 'score' => 118] ]; function meilleurJoueur($tab){ $bestScore=0; $nom=''; foreach ($tab as $c=>$v){ if($v['score']>$bestScore){ $bestScore=$v['score']; $nom=$v['nom']; } } echo $nom.' : '.$bestScore; } meilleurJoueur($joueurs); ?>

    Exercice 8 :

    montant = $montantInit; if (((string) $int) === ((string)(int) $int)) $this->interet = $int; } public function get_montant(){ return $this->montant; } public function un_an(){ $this->montant+=$this->montant*($this->interet/100); } } $compte1=new Compte(200,20); $compte2=new Compte(1000,2); echo 'compte 1 : '.$compte1->get_montant().'
    '; echo 'compte 2 : '.$compte2->get_montant().'
    '; for ($i=0;$i<10;$i++){ $compte1->un_an(); $compte2->un_an(); } echo 'compte 1 après 10 ans : '.$compte1->get_montant().'
    '; echo 'compte 2 après 10 ans : '.$compte2->get_montant().'
    '; ?>

    Exercices 9 à 11 :

    nombre :

    reinitialiser la session

    Exercice 13 :

    Exercice 13.2 :

    "; else echo "non
    "; if (preg_match($reg,'bjour') && preg_match($reg,'jour') && preg_match($reg,'jr')) echo "oui
    "; else echo "non
    "; if (preg_match($reg,'our') && preg_match($reg,'jour') && preg_match($reg,'j')) echo "oui
    "; else echo "non
    "; ?>

    Exercice 13.3 :

    "; else echo "non
    "; if (preg_match($reg,'a.bc') && preg_match($reg,'aabbaaa') && preg_match($reg,'anbc')) echo "oui
    "; else echo "non
    "; if (preg_match($reg,'aabc') && preg_match($reg,'aabbababa') && preg_match($reg,'anbc')) echo "oui
    "; else echo "non
    "; ?>