Page 1 sur 1

boucle infini

Posté : 01 juil. 2009, 11:36
par x@v
Bonjour,
j'ai une boucle qui fait tourner le navigateur à l'infini ?
	<?php 
	$pas=1;
	$dateDebut=$dateCourante-20;
	//echo $dateCourante;
	for ($dateCourante=date('Y'); $dateCourante > $dateDebut; $index--) {
			echo $dateCourante;
	}
	?>
j'ai aussi fait ça
	<?php 
	$dateCourante=date('Y');
	echo $dateCourante;
	for ($index = 1900; $index < $dateCourante; $index--) {
		$dateDebut=$dateCourante-20;
		if ($dateCourante > $dateDebut) {
			echo $dateCourante;
		}
	}
	?>
j'ai trouvé :)
	<?php 
	$dateCourante=date('Y');
	echo $dateCourante;
	for ($index = 1; $index < 20; $index++) {
			echo $dateCourante-$index;
	}
	?>	
Merci

Posté : 01 juil. 2009, 11:40
par julian
Que contient la variable $dateDebut juste avant la boucle ?

Posté : 01 juil. 2009, 11:43
par x@v
j'ai trouvé
	<?php 
	$dateCourante=date('Y');
	echo $dateCourante;
	for ($index = 1; $index < 20; $index++) {
			echo $dateCourante-$index;
	}
	?>	

Chuck noris est toujours résolus :)

Posté : 02 juil. 2009, 04:28
par AB
j'ai trouvé
	<?php 
	$dateCourante=date('Y');
	echo $dateCourante;
	for ($index = 1; $index < 20; $index++) {
			echo $dateCourante-$index;
	}
	?>	

Chuck noris est toujours résolus :)
Ah bah ... cliquer sur "résolu" permet aussi aux prochains visiteurs de savoir que le sujet contient une solution, et à ceux qui veulent aider de savoir qu'il n'est pas besoin d'aller voir le topic :wink: