3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "0-1-1-3-1-1-3-5-0"; $array = explode('-', $input); $result = array_unique($array) + array_fill(0, count($array), 0); ksort($result); var_dump(implode('-',$result));
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
string(17) "0-1-0-3-0-0-0-5-0"

preferences:
140.33 ms | 407 KiB | 5 Q