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)); echo "\n---\n"; var_export(preg_split('#\.\w{3}\K(?=\.\./)#', $filepaths));
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
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', ) --- 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:
41.73 ms | 409 KiB | 5 Q