sorting a list using regex
| From: | Joshua E Minnie | Date: | Wed, 05 Jun 2002 18:58:07 +0000 |
| Subject: | sorting a list using regex | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100764@lists.php.net to get a copy of this message | ||
I am trying to sort a list by their first character, my problem comes when
that first character is a number. When the character is a number I should
be able to display just the values which begin with a number. When the
value is a letter, I have no problem sorting this out. Here is the code
that I am using to determine that, any help will be greatly appreciated.
<?
[snip]
while(!feof($fp)) {
$artist = fgetcsv($fp,128,":");
if(isset($_GET["sort"])) {
if(($_GET["sort"] != substr(strtoupper($artist[0]),0,1)) ||
($_GET["sort"] == "0-9" && !preg("^[0-9]",$artist[0])))
continue;
}
// do something here
}
[snip]
?>
Running PHP 4.2.1 on IIS 5 W2K
Thanks
-josh