[RESOLU] integrer html dans php

Eléphant du PHP | 166 Messages

09 nov. 2017, 19:23

Bonjour
voici mon code :

Code : Tout sélectionner

$i = 0; while ($i <= $nbeleve) { $i++;//affecte nb d'eleves $nsport = rand(0,3);//affecte 0 à 3 sport/élève $sport = array('Aucun sport','Boxe','Foot','Tennis','Velo','Piscine');//création tableau sports switch ($nsport) { case 0: $zero = $sport[0];//Select aucun sport du tableau echo $zero .'</br>';//on affiche break; case 1: $rand_keys1 = array_rand($sport,1);//select 1 valeur au hazard du tableau $sport echo $sport[$rand_keys1] .'</br>';//on affiche var_dump($rand_keys1); break; case 2: $rand_keys2 = array_rand($sport,2);//select 2 valeurs au hazard du tableau $sport echo $sport[$rand_keys2[0]] .'</br>';//on affiche echo $sport[$rand_keys2[1]] .'</br>';//on affiche break; case 3: $rand_keys3 = array_rand($sport,3);//select 3 valeurs au hazard du tableau $sport echo $sport[$rand_keys3[0]] .'</br>';//on affiche echo $sport[$rand_keys3[1]] .'</br>';//on affiche echo $sport[$rand_keys3[2]] .'</br>';//on affiche break; }
je voudrais distinguer chaque CASE par une couleur, ex : case 0 en rouge, case 1 en vert, etc...
j'ai toujours du mal a integré du html dans le php.
je tente des choses du style :
echo '<p id="rouge">$sport[$rand_keys3[0]] </p>';
mais pas bon....

Mammouth du PHP | 2703 Messages

09 nov. 2017, 19:37

echo '<p id="rouge">'.$sport[$rand_keys3[0]].' </p>';

Eléphant du PHP | 166 Messages

12 nov. 2017, 01:21

Merci