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: 
Assuming your elements are stored in an array you can use the `shuffle()` function:

```
$a = array('a', 'b', 'c');
shuffle($a);

```

This leads to a random sort of `$a`.
I would use the DOM class: <http://php.net/manual/en/book.dom.php> and a DFS to mix the first level of the tree.