View Single Post
Old 01-27-2008, 03:10 PM   #5 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

This is the code I would use to do it. However, although you can calculate the identifier on-the-fly, if you introduce any more characters into it then consider storing it in the database so you can be certain it can be reversed.

php Code:
class String
{
    /* Bring on namespaces! */
    public static function toSef($szText)
    {
        $szText = str_replace(' ', '-', $szText);
        return preg_replace('~[^-a-z0-9]~i', '', $szText);
    }
}

echo String::toSef('this is a "test"');
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote