<?php
$list = [
'10-20',
'12-14',
'-5-10',
'-10--2'
];
foreach ($list as $item) {
list($first, $second) = preg_split('/(?<=\d)-/', $item);
echo "\$first = $first, \$second = $second\n";
}
- Output for 7.1.25 - 7.1.33, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- $first = 10, $second = 20
$first = 12, $second = 14
$first = -5, $second = 10
$first = -10, $second = -2
preferences:
221.91 ms | 403 KiB | 184 Q