Sort html string in alphabetical order using PHP
<p>See code below. I want to sort the option tags by name, not by id.</p>

<p>Here is my code:</p>

<pre><code>&lt;?php

$string = '&lt;option id=a1&gt;Sinead Shannon Roche&lt;option id=a2&gt;Emile Abossolo Mbo&lt;option id=a3&gt;Youssouf Djaoro&lt;option id=a4&gt;Dioucounda Koma';
$new_string = '';

$s = explode('&lt;', $string);
asort($s);
foreach($s AS $v) {
    $new_string = $new_string . '&lt;' . $v;
}

// I want $new_string to be "&lt;option id=a4&gt;Dioucounda Koma&lt;option id=a2&gt;Emile Abossolo Mbo&lt;option id=a1&gt;Sinead Shannon Roche&lt;option id=a3&gt;Youssouf Djaoro"

?&gt;
</code></pre>
