Trying to figure out a way to perform string manipulation in php. In the example below I need to recognize all instances of [backspace] and remove them from the string, BUT I also need to remove the character immediately before it as well.
$string = "this is a sentence with dog[backspace][backspace][backspace]cat in it";
would become "this is a sentence with cat in it".
My initial thought was turning the string into an array and performing the operation that way somehow as I don't believe there is any way I could do this with str_replace.
$array = str_split($string);
foreach($array as $key)
{
.. lost here
}
[backspace]as a literal backspace operation? So since you have 3 of those in a row here it deletesd-o-g?