View Full Version : text to ascii function?
themoose
November 18th, 2007, 16:25
Does anybody know where I can find a function in php that does a similar job to this?
http://getyourwebsitehere.com/jswb/text_to_ascii.html
(note: i'm NOT looking for urlencode etc).
edit: similar to htmlentities but for every character.
krakjoe
November 18th, 2007, 18:03
No, I dunno how to do that ....
<?php
function str2ascii( $string )
{
$ascii = array( );
for( $i = 0; $i < strlen( $string ); $i++ ) $ascii[ $i ] = sprintf( "&#%d;", ord( $string{$i} ) );
return implode( null, $ascii );
}
echo str2ascii( "my ascii string will be output as normal html" );
?>
...
themoose
November 19th, 2007, 14:03
Was that sarcasm or will that be what I need?
edit/ it is :D thanks!
krakjoe
November 19th, 2007, 14:50
Really, you thought I was serious ??
I'm insulted ...
themoose
November 19th, 2007, 15:03
I'm sorry. I never doubted you, I just thought you hadn't bothered yet :P.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.