make a file names str2ascii.php and paste the following code in it.
demo:
http://www.mct-hosting.com/str2ascii.php
demo:
http://www.mct-hosting.com/str2ascii.php
PHP:
<?php
function str2ascii($string) {
$ascii = array( );
for( $i = 0; $i < strlen( $string ); $i++ ) $ascii[ $i ] = sprintf( "&#%d;", ord( $string{$i} ) );
return implode( null, $ascii );
}
if($_POST){
$find = array('&#32;');
$replace = array(' ');
$str = htmlentities(str2ascii($_POST['plainTXT']), ENT_QUOTES);
$fixedSTR = str_replace($find, $replace, $str);
$str = $fixedSTR;
}
?>
<form action="str2ascii.php" method="post">
Plain Text Here:<br>
<textarea name="plainTXT" cols="50" rows="8"><?=$_POST['plainTXT'];?></textarea>
<br><br>
Converted Ascii Text Here:<br>
<textarea name="asciiTXT" cols="50" rows="8" wrap="hard"><?=$str;?></textarea>
<br><br>
<input name="Submit" type="submit" value="Convert to Ascii">
</form>
Last edited: