Unifix knowledge database - The original one

Dashboard - News - Search - List - About - Admin


Check om en streng kun indeholder bogstaver og mellemrum

Author:mike - Sat Jan 28 13:44:46 2006

function IsAlpha($char)
{
        if (preg_match("/[a-z;A-Z]/",$char))
        { return true; }
        else if (in_array(htmlentities($char),explode(" ","æ &Aelig; ø Ø å Å")))
        { return true; }
        else if ($char == " ")
        { return true; }
        else
        { return false; }
}

function StripSigns($string)
{
        for ($i=0; $i<=strlen($string); $i++)
        {
                if (IsAlpha($string[$i]))
                {
                        $str=$str.htmlentities($string[$i]);
                }
        }
        return $str;
}


print StripSigns("Søren 23423"#%€#!%!#€ Peter");

Vil returnere Søren Peter
Copyright(c) Unifix.org 2002-2011


Dashboard - News - Search - List - About - Admin
 
Powered by Mikjaer Consulting Solutions - Hosted by Specialhosting.dk