3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'abc-def-ghi::State.32.1.14.16.5:A'; var_export( preg_split( '/(?:[^:]*\K:){3}/', $string ) ); $string = 'def-ghi::yellow:abc::def:B'; var_export( preg_split( '/(?:[^:]*\K:){3}/', $string, 2 # instruct to not explode more than once (limit generated elements to a max of 2) ) );
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 0 => 'abc-def-ghi::State.32.1.14.16.5', 1 => 'A', )array ( 0 => 'def-ghi::yellow', 1 => 'abc::def:B', )

preferences:
102.39 ms | 1256 KiB | 4 Q