I have this function that strips illegal characters. I found it here http://php.net/manual/en/function.strtr.php, function fixoutput($str)
So, this is my code.
<?php
$stuff = 'Foo ◻◻◻◻◻◻◻◻◻◻◻◻';
function fix_output($str){
$newstr = '';
$good[] = 9; #tab
$good[] = 10; #nl
$good[] = 13; #cr
for($a=32;$a<127;$a++){
$good[] = $a;
}
$len = strlen($str);
$strs = array();
for($b=0;$b < $len+1; $b++){
if(in_array(ord($str[$b]), $good)){
$newstr .= $str[$b];
}//fi
}//rof
return $newstr;
}
echo fix_output($stuff);
echo '<br>'.$stuff;
And I have this output.
Notice: Uninitialized string offset: 40 in /<directory>/foo/foo.php on line 17
Foo
Foo ◻◻◻◻◻◻◻◻◻◻◻◻
I want a fix for this notice.
I'm having this notice because is $str
a string in this context, not an array. I am are trying to treat it like an array, which doesn't work. I'm having trouble in creating a fix for this, could you guys lend me some ideas? Thanks a bunch!
Please mention the things that are unclear.