On the first line you will receive a string. On the second line you will receive a second string. Write a program that removes all of the occurrences of the first string in the second until there is no match. At the end print the remaining string.
Examples:
My solution:
<?php $replacement = readline(); $str = readline(); $count = 1; while ($count > 0) { $strNew = str_replace($replacement, "", $str, $count); if ($str == $strNew) { break; } else { $str = $strNew; } } echo $strNew;
This is mine code:
<?php $replacement = readline(); $str = readline(); while (true) { $strNew = str_replace($replacement, "", $str); if ($str == $strNew) { break; } else { $str = $strNew; } } echo $strNew;
This one is mine:
<?php $replacement = readline(); $str = readline(); while (strpos($str, $replacement) !== false) { $str = str_replace($replacement, "", $str); } echo $str;
622 questions
979 answers
129 comments
53 users