ForEach Array打印数字1-200

时间:2016-04-01 21:14:37

标签: php

我试图创造一些允许我进入ForEach的东西 每次创建不同的数字。

例如: 1 TEAM24SEVEN | 1395LP | 159Wins | 51Losses 2 Gilius 1v9 | 1315LP | 148Wins | 62Losses 3 FNC Sp1rit | 1204LP | 135Wins | 45Losses

这是我需要在以下代码中实现的代码:

<?php 

$rank = 0+1; 
$entries = $getchallengerleaguerankingList->entries;
usort($entries, function($a,$b){
return $b->leaguePoints-$a->leaguePoints;
});

foreach($entries as $statSummaryz){
print '<p>'.$rank.'</p><p><b>' .$statSummaryz->playerOrTeamName. '</b> | <font color="blue">' .$statSummaryz->leaguePoints. '</font>LP | <font color="green">' .$statSummaryz->wins. '</font>Wins | <font color="red">' .$statSummaryz->losses.'Losses </font></p>';
}
?>

1 个答案:

答案 0 :(得分:0)

您只需每次迭代递增变量

foreach($entries as $statSummaryz){
    print '<p>'.$rank.'</p><p><b>' .$statSummaryz->playerOrTeamName. '</b> | <font color="blue">' .$statSummaryz->leaguePoints. '</font>LP | <font color="green">' .$statSummaryz->wins. '</font>Wins | <font color="red">' .$statSummaryz->losses.'Losses </font></p>';
    $rank++;
}