$v){ if(!in_array($n, array('startingPoint','endingPoint','largeur','hauteur'))){ $coord = getCoordForCase($n); $cases[$coord[0]][$coord[1]] = 1; } } function getCoordForPt($t){ if (preg_match('/^check(\d{1,2})-(\d{1,2})$/', $t, $m) !== 0) { return '[' . $m[2] . ',' . $m[1] . ']'; } return null; } function getCoordForCase($t){ if (preg_match('/^check(\d{1,2})-(\d{1,2})$/', $t, $m) !== 0) { return [$m[1], $m[2]]; } return null; } $level = '['; for($i=0; $i<$hauteur; $i++){ $level .= '['; for($j=0; $j<$largeur; $j++){ if(!empty($cases[$i][$j])) { $level .= '1,'; } else { $level .= '0,'; } } $level = substr($level, 0, -1).'],'; } $level = substr($level, 0, -1).'];'; $file = ''; $file .= 'currentPosition = '.getCoordForPt($startingPoint).';'; $file .= 'finalPosition ='.getCoordForPt($endingPoint).';'; $file .= 'level = '.$level; $tod = gettimeofday(); $finalFilename = $tod['sec'].mt_rand(0,50).'.js'; file_put_contents(__DIR__ .'/custom/'.$finalFilename, $file); $_SESSION['file'] = $finalFilename; header('Location: list/');