par
Ryle » 20 mai 2006, 11:14
C'est franchement pas beau comme code...
pourquoi pas tout simplement initialiser ta variable à -1, ou incrémenter seulement après utilisation ?
$compte = -1;
echo "photo" . $compte++; // affiche "photo0" et $compte égal 0
echo "photo" . $compte++; // affiche "photo1" et $compte égal 1
// ou
$compte = 0;
echo "photo" . ++$compte; // affiche "photo0" et $compte égal 1
echo "photo" . ++$compte; // affiche "photo1" et $compte égal 2
C'est franchement pas beau comme code...
pourquoi pas tout simplement initialiser ta variable à -1, ou incrémenter seulement après utilisation ?
[php]$compte = -1;
echo "photo" . $compte++; // affiche "photo0" et $compte égal 0
echo "photo" . $compte++; // affiche "photo1" et $compte égal 1
// ou
$compte = 0;
echo "photo" . ++$compte; // affiche "photo0" et $compte égal 1
echo "photo" . ++$compte; // affiche "photo1" et $compte égal 2[/php]