3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strings = [ 'this/is/the/path/to/my/fileA.php', 'this/could/also/be/the/path/to/my/fileB.php', 'another/example/of/a/long/address/which/is/a/path/to/my/fileC.php', ]; var_export( preg_replace( '~(?:/[^/]*){4}$~', '', $strings ) );
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
array ( 0 => 'this/is/the', 1 => 'this/could/also/be/the', 2 => 'another/example/of/a/long/address/which/is/a', )

preferences:
83.35 ms | 1141 KiB | 4 Q