Ordering a variable

Hi

I have a variable like this

$order=’
Chris
Rob
David
';

Is there any way I can order this by alphabet?

Thanks in advance

Chris


<?php
$order = '
Chris
Rob
David
';

preg_match_all('~[a-z]+~i', $order, $matches);

$array = array_shift($matches);

sort($array);

$order = "\
" . implode("\
", $array) . "\
" ;

var_dump(
  $order
);

/*
  string(17) "
  Chris
  David
  Rob
  "
*/

thats cool but i forgt to add there are also surnames there as well

$order='
Chris Smith
Rob Jones
David Hughes
';

Would still need to order by first name

$order = explode("\
",trim($order));
sort($order);
$order = implode("\
",$order);

Note: This will choke a bit on blank lines. If you need to accomodate that, the code will need to change.

Deja vu.

Do you suffer amnesia or are you mocking?