Answer the question
In order to leave comments, you need to log in
How to write a function that returns a string without the deleted character?
Prompt with code.
This code should remove the passed character, which is in the variable $sim
of the string, which is in the variable $str
, using a loop and a condition in it, but I cannot make this character be removed from the string.
I am trying to remove a character using decriment.
As I understand it, you need to do something like this:
<?
function filterString($str, $sim) {
$index = strlen($str);
while($sim != $index) {
if($sim === $index) {
return —$sim;
} else {
return $str;
}
return —$sim;
}
}
filterString('Hello world', 'l');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question