hi guys,
i have an associative array $mydb that looks like this with print_r() …
Array ( [user1] => 135 [user2] => 16 [user3] => 16 )
(it has more than 30 users)
is it possible to create a for loop that will echo the contents of
the first 10 users only?
i tried this …
for( $i = 0; $i < sizeof($mydb); $i++ ){
if( $i < 10 ){
$ifix = $i + 1;
echo “<tr><td>$ifix</td><td>$mydb[$i][0]</td><td>$mydb[$i][1]</td></tr>”
}
}
i want it t create a table of the top ten users with the
first cell being their position,
the second being their username and
the third cell being the number of point accumulated
so the above should be outputted as …
<tr><td>1</td><td>user1</td><td>135</td></tr>
<tr><td>2</td><td>user2</td><td>16</td></tr>
<tr><td>3</td><td>user3</td><td>6</td></tr>
this works …
foreach ($mydb as $key => $value){
echo “<tr><td><b>” . $key . “</b></td><td>” . $value . “</td></tr>”;
}
but i can’t show their position as 1st, 2nd, 3rd, etc or
make it stop after echoing the first ten users
please help