3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '1-string-2-string-3-string-55-otherstring-66-otherstring'; print_r(implode('-', array_reverse(array_unique(array_reverse(explode('-', $str))))));

preferences:
31.82 ms | 408 KiB | 5 Q