3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'this is a returned string'; $words = explode(" ", $string ); $last_two_word = implode(' ',array_splice($words, -2 )); $except_last_two = implode(' ', $words); $expected = '<p>'.$except_last_two.' <span class="someclass">'.$last_two_word.'</span></p>'; echo $expected; ?>

preferences:
25.42 ms | 406 KiB | 5 Q