Question: I have some markup like so:

```
<div class="list">

    <article> content... </article>
    <article> content... </article>
    <article> content... </article>
    <article> content... </article>
    <article> content... </article>

</div>

```

What I want to do is make the order of what these articles appears on the page random. What would be the best and easiest way to do this?

I thought about doing some sort of length count and storing it in an array and then spitting them back out again in a random order. e.g.

```
$numbers = range(1, 20);
shuffle($numbers);
foreach ($numbers as $number) {
    echo "$number ";
}

```

Can anyone offer ideas etc? Thanks

**NOTE: These are not coming from a database!**

Answer: 
[Every day I'm shuffling!](http://php.net/manual/en/function.shuffle.php)

But yeah, having your contents in a PHP array, then displaying them all through a little `foreach` would be fine. Example :

```
$content = array('content1', 'content2', 'content3');
shuffle($content);
echo '<div>';
foreach($content as $value) {
  echo '<article>', $value, '</article>';
}
echo '</div>';

```
When dealing with something slightly more complicated than echoing out chunks of HTML from a database, you want to look at the [`DOMDocument` class](http://il.php.net/manual/en/class.domdocument.php). It will assist you with manipulating the HTML (a.k.a. the DOM) in any way you'd like.