La récursivité

Résumé Support

Dans ce tutoriel vidéo nous allons voir comment utiliser la Récursivité pour résoudre des problèmes complexes.

Code source du labyrinthe :

<?php /** * Génération et affichage du parcours * */ $tmp = "1110000111110000011 0000000100000001110 1100000100100111000 0111111100100100100 0000000111111100100 000000000000111100"; $maze = array(); $tab = explode("\n",$tmp); ?> <table> <?php $y=0; foreach($tab as $v): ?> <tr> <?php $length = strlen($v); //taille de la chaine $x = 0; for($i=0;$i<$length-1;$i++): $value = mb_substr($v, $i, 1);// Valeur de la case $maze[$x][$y] = $value; ?> <td style="width:30px; height:30px; background:<?php echo $value==1 ? "#00FF00" : "#FF0000"; ?>"> </td> <?php $x++; endfor; ?> </tr> <?php $y++; endforeach; ?> </table>