3v4l.org

run code in 300+ PHP versions simultaneously
<?php $example = 'your string here, please/do it by yourself.'; $expected = 'your string here, do it by yourself.'; $slashPos = strpos($example, '/'); $spacePos = strrpos($example, ' ', -1 * $slashPos); $string1 = substr($example, 0, $spacePos + 1); $string2 = substr($example, (strlen($example) - $slashPos - 1) * -1); $result = $string1 . $string2; var_dump(assert($expected === $result));

preferences:
31.5 ms | 408 KiB | 5 Q