View Single Post
Old 10-20-2005, 10:14 AM   PM User | #27
r0n1n
New to the CF scene

 
Join Date: Oct 2005
Location: Torquay
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
r0n1n is an unknown quantity at this point
regexp

I know it's PHP but I thought somone was bound to know the JavaScript syntax for the regexp check.

<?php

$days = range(1, 31);

foreach($days as $day)
{
if(ereg("(^[23]?1$)", $day))
{
$suff = "st";
}
elseif(ereg("(^2?2$)", $day))
{
$suff = "nd";
}
elseif(ereg("(^2?3$)", $day))
{
$suff = "rd";
}
else
{
$suff = "th";
}

echo $day . $suff . "<br />";
}
?>

Last edited by r0n1n; 10-20-2005 at 11:36 AM.. Reason: code sucked
r0n1n is offline   Reply With Quote