Can anyone tell me what's wrong with this code..? All's I need my script to do is cycle thru a given string and turn any ASCII characters greater than 127 into HTML entities:
////////////////START////////////////////
$trans=get_html_translation_table(HTML_SPECIALCHARS);
for($j=0; $j<= strlen($string); $j++){
//cycle through each character in a string & count the # of opening and closing brackets
$lessthan= substr_count($string[$j], "<");
$greatthan= substr_count($string[$j], ">");
if($lessthan != 0){ ++$lesscount;
}
if($greatthan != 0){ ++$greatcount;
}
$stat=$greatcount + 1;
if (ord($string[$j]) > 127 && $stat != $lesscount){
/
If the ASCII value of the current character is > than 127 it is a special character. Translate the entity reference for the character and put it back into the string.
/
$fixstring .= strtr($string[$j], $trans);
}else{
//Else just place the character back into the string.
$fixstring .= $string[$j];
}
/////////End///////////