Hi,
(my first post was not clear and confusing so I've edited the question)
I was studying string manipulation. You can use strlen() or substr() but cannot rely on other functions that are predefined in libraries.
Given string $string = "This is a pen"
, remove "is"
so that
return value is "Th a pen"
(including 3 whitespaces).
Remove 'is' means if a string is "Tsih", we don't remove it. Only "is" is removed.
I've tried (shown below) but returned value is not correct. I've run test test and I'm still capturing the delimiter.
Thanks in advance!
function remove_delimiter_from_string(&$string, $del) {
for($i=0; $i<strlen($string); $i++) {
for($j=0; $j<strlen($del); $j++) {
if($string[$i] == $del[$j]) {
$string[$i] = $string[$i+$j]; //this grabs delimiter :(
}
}
}
echo $string . "\n";
}