3v4l.org

run code in 300+ PHP versions simultaneously
<?php function common_parts($data) { for ($b = 1; ; $b *= 10) { $base = intdiv($data[0], $b); $matches = array_filter($data, function ($v) use ($b, $base) { return intdiv($v, $b) != $base; }); if (count($matches) == 0) break; } $base *= $b; for ($i = 1; $i < count($data); $i++) { $data[$i] = $data[$i] - $base; } return $data; } print_r(common_parts(array(670006151,670006152,670006251))); print_r(common_parts(array(670006151,670006154,670006158))); print_r(common_parts(array(670006151,670006154,670006161)));

preferences:
74.99 ms | 406 KiB | 5 Q