Source Rally PHP Community Scripts .. Sign up .. Login
This is a little bit more efficient version of regins entity converter. ;-)
Access: Public      Tags: php, xml, xhtml, entities
Add to favourites       Subscribe comments       Copy code       Bookmark
<?php
function xmlEntities($string)
{
    
$return '';    

    for(
$i 0$i strlen($string); $i++)
    {
        
$ascii ord($string{$i});
        
        if((
$ascii >= 48 && $ascii <= 57) ||
            (
$ascii >= 65 && $ascii <= 90) ||
            (
$ascii >= 97 && $ascii <= 122))
        {
            
$return .= $string{$i};
        }
        else
        {
            
$return .= '&#'.$ascii.';';
        }
    }

    return 
$return;
}
?>
Add to favourites       Subscribe comments       Copy code       Bookmark
Sign up to add your own comment here!

Shared by:

Floriam

Mail user Add to friends
All user contributed content is available under the LGPL unless specified otherwise.
Remaining copyrights Regin Gaarsmand © 2006-2008
About SourceRally.net
Programador PHP