, несмотря на часы работы в Интернете и чтение различных книг. Я не могу представить, на что я нацелен в PHP-программе, которую я пытаюсь создать (я новичок в этом!). В принципе, для начала я просто хотел создать простой массив и попытаться вывести свои любимые футбольные команды, их позицию или факты о них, прежде чем я попаду во что-то слишком сложное (к счастью, даже это было сложно!). Это то, что я получил до сих пор:Выходной массив PHP
<?php
<html>
<head>
<title>Football teams</title>
</head>
<body>
<?php
$numbers = array("one", "two", "three", "four");
$counter = 0;
do {
if($counter > 0) {
$verse = true;
}
echo "$numbers[$counter] " ;
if ($verse) {
echo "Team " ;
}
else {
echo "Teams" ;
}
print "are the best teams in the world <br/>" ;
$counter++;
} while($counter < 4);
$football = $counter;
while($football) {
echo "$numbers[$football] men, " ;
if ($verse) {
echo "n<br/>" ;
}
echo "and rarely lose any games\n\n<br/><br/>" ;
$football--;
}
?>
</body>
</html>
Теперь, когда работает без каких-либо ошибок, но все это за место и не в правильном порядке, так что я бы признателен за любую помощь. Не могу понять, что не так, когда ошибок нет, поэтому я подозреваю, что есть проблема с одним из циклов.
спасибо.
Я ожидаю получить:
т.д.
Но то, что я получаю:
one team are the best team in the world
two teams are the best team in the world
three teams are the best team in the world
four teams are the best team in the world
UPDATE:
$counter = 0;
do {
if($counter > 0) {
$verse = true;
}
echo "$numbers[$counter] " ;
if ($verse) {`
echo "team " ;
}
else {
echo "teams " ;
}
print "are the best teams in the world<br/>" ;
$football = $counter;
while($football) {
echo "$numbers[$football] teams, " ;
if ($verse) {
echo "<br/>" ;
}
echo "and rarely lose any games\n\n<br/><br/>" ;
$mower--;
}
$counter++;
} while($counter < 10);
?></body>
</html>
Используя этот код I Я почти достиг своей цели, это t он выход я получаю:
one team are the best team in the world,
two teams are the best team in the world,
two teams,
and rarely lose any games
three teams are the best team in the world,
three teams,
and rarely lose any games
two teams,
and they rarely lose any games,
four teams are the best team in the world,
four teams,
and they rarely lose any games,
НО, ЧТО Я ХОЧУ ЭТО:
one team are the best team in the world,
and they rarely lose any games,
two teams are the best team in the world,
two teams,
and they rarely lose any games,
three teams are the best team in the world,
three teams, two teams,
and they rarely lose any games,
four teams are the best team in the world,
four teams, three teams, two teams,
and they rarely lose any game,
Спасибо, если кто-то может помочь !!
отступа код Проклятье !! –
Я думал, что знаю, не знаю, что случилось. Должен ли я удалять и репонировать? – 2013-03-19 20:27:50
следует отложить теперь, пожалуйста, проверьте –