Skip to content
Advertisement

php foreach count rows with style positions

I’m trying to create Contest list of users in php.

But my code style don’t give me what I want

My code:

<?php

$users = ["129292199", "616161616", "272727272", "555554433", "666665886"];
$count = 0;

foreach ($users as $name){
    $count += 1;
    echo  "{$count} $namen";
}

?>

My code output

1 129292199
2 616161616
3 272727272
4 555554433
5 666665886

But I want something like this

👑 1st : 5453674081
🥈 2nd : 135678975
🥉 3rd : 5607170108
4️⃣ 4th : 1460057759
5️⃣ 5th : 1664868970

Advertisement

Answer

you can wrap the count variable inside a class and style it with css

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement