<?php
$input = "0-1-1-3-1-1-3-5-0";
$array = explode('-', $input);
$result = array_replace(array_fill(0, count($array), 0), array_unique($array));
var_export($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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14
- array (
0 => '0',
1 => '1',
2 => 0,
3 => '3',
4 => 0,
5 => 0,
6 => 0,
7 => '5',
8 => 0,
)
preferences:
70.73 ms | 407 KiB | 5 Q