3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filepaths = '../images/box1/IMG_3158.JPG../images/box1/IMG_3161.JPG../images/box1/IMG_3163.JPG../images/box1/IMG_3158.JPG../images/box1/IMG_3161.JPG../images/box1/IMG_3163.JPG'; var_export(preg_split('/\.JPG\K(?!$)/', $filepaths)); echo "\n---\n"; var_export(preg_split('/(?!^)(?=\.\.)/', $filepaths)); echo "\n---\n"; var_export(preg_split('/\.JPG\K/', $filepaths, 0, PREG_SPLIT_NO_EMPTY)); echo "\n---\n"; var_export(preg_split('/(?!^)(?=\.\.)/', $filepaths, 0, PREG_SPLIT_NO_EMPTY));
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
array ( 0 => '../images/box1/IMG_3158.JPG', 1 => '../images/box1/IMG_3161.JPG', 2 => '../images/box1/IMG_3163.JPG', 3 => '../images/box1/IMG_3158.JPG', 4 => '../images/box1/IMG_3161.JPG', 5 => '../images/box1/IMG_3163.JPG', ) --- array ( 0 => '../images/box1/IMG_3158.JPG', 1 => '../images/box1/IMG_3161.JPG', 2 => '../images/box1/IMG_3163.JPG', 3 => '../images/box1/IMG_3158.JPG', 4 => '../images/box1/IMG_3161.JPG', 5 => '../images/box1/IMG_3163.JPG', ) --- array ( 0 => '../images/box1/IMG_3158.JPG', 1 => '../images/box1/IMG_3161.JPG', 2 => '../images/box1/IMG_3163.JPG', 3 => '../images/box1/IMG_3158.JPG', 4 => '../images/box1/IMG_3161.JPG', 5 => '../images/box1/IMG_3163.JPG', ) --- array ( 0 => '../images/box1/IMG_3158.JPG', 1 => '../images/box1/IMG_3161.JPG', 2 => '../images/box1/IMG_3163.JPG', 3 => '../images/box1/IMG_3158.JPG', 4 => '../images/box1/IMG_3161.JPG', 5 => '../images/box1/IMG_3163.JPG', )

preferences:
43.76 ms | 409 KiB | 5 Q