Reputation: 705
I have ten spans in my css, all with different widths: span1, span2, span3..., span10.
I'd like to loop an array of posts and display every posts in randomized span names...
How could I achieve something like this without hardcoding spans in the html and using multiple queries?
Upvotes: 0
Views: 43
Reputation:
<?php
$posts=array('a','b','c');
$rand=range(1,10);
shuffle($rand);
$count=current($rand);
foreach($posts as $p){
echo '<span style="css'.$rand[$count].'">'.$p.'</span>';
$count=next($rand);
}
Upvotes: 1