3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ( ! function_exists( 'str_ends_with' ) ) { function str_ends_with( $haystack, $needle ) { // Yes, I know, but I'm coding on mobile. forgive_me() return 0 === strpos( strrev( $haystack ), strrev( $needle ) ); } } $dirlist = array ( 'folder' => array ( 'name' => 'folder', 'perms' => 'urwxr-xr-x', 'permsn' => '0755', 'number' => false, 'owner' => false, 'group' => false, 'size' => 4096, 'lastmodunix' => 1673689008, 'lastmod' => 'Jan 14', 'time' => '09:36:48', 'type' => 'd', 'files' => array ( 'subfile.php' => array ( 'name' => 'subfile.php', 'perms' => 'urw-r--r--', 'permsn' => '0644', 'number' => false, 'owner' => false, 'group' => false, 'size' => 0, 'lastmodunix' => 1673689008, 'lastmod' => 'Jan 14', 'time' => '09:36:48', 'type' => 'f', ), 'subfolder' => array ( 'name' => 'subfolder', 'perms' => 'urwxr-xr-x', 'permsn' => '0755', 'number' => false, 'owner' => false, 'group' => false, 'size' => 4096, 'lastmodunix' => 1673689982, 'lastmod' => 'Jan 14', 'time' => '09:53:02', 'type' => 'd', 'files' => array ( 'subsubfile.php' => array ( 'name' => 'subsubfile.php', 'perms' => 'urw-r--r--', 'permsn' => '0644', 'number' => false, 'owner' => false, 'group' => false, 'size' => 0, 'lastmodunix' => 1673689982, 'lastmod' => 'Jan 14', 'time' => '09:53:02', 'type' => 'f', ), ), ), ), ), 'file.php' => array ( 'name' => 'file.php', 'perms' => 'urw-r--r--', 'permsn' => '0644', 'number' => false, 'owner' => false, 'group' => false, 'size' => 0, 'lastmodunix' => 1673689019, 'lastmod' => 'Jan 14', 'time' => '09:36:59', 'type' => 'f', ), ); $path = trailingslashit( '/root' ); echo headerme( 'Expected' ); echo $path, 'folder/subfile.php', PHP_EOL; echo $path, 'folder/subfolder/subsubfile.php', PHP_EOL; echo $path, 'file.php', PHP_EOL; echo headerme( 'array_walk_recursive()' ); array_walk_recursive( $dirlist, function ( $value, $key, $path ) { if ( str_ends_with( $value, '.php' ) ) { echo $path, $value, PHP_EOL; } }, $path ); echo headerme( 'map_deep()' ); map_deep( $dirlist, function( $value ) use ( $path ) { if ( str_ends_with( $value, '.php' ) ) { echo $path, $value, PHP_EOL; } } ); echo headerme( 'map_deep_with_index()' ); map_deep_with_index( $dirlist, function( $value, $key ) use ( $path ) { if ( str_ends_with( $value, '.php' ) ) { echo $path, $value, PHP_EOL; } } ); function map_deep( $value, $callback ) { if ( is_array( $value ) ) { foreach ( $value as $index => $item ) { $value[ $index ] = map_deep( $item, $callback ); } } elseif ( is_object( $value ) ) { $object_vars = get_object_vars( $value ); foreach ( $object_vars as $property_name => $property_value ) { $value->$property_name = map_deep( $property_value, $callback ); } } else { $value = call_user_func( $callback, $value ); } return $value; } function map_deep_with_index( $value, $callback, $index = null ) { if ( is_array( $value ) ) { foreach ( $value as $index => $item ) { $value[ $index ] = map_deep_with_index( $item, $callback, $index ); } } elseif ( is_object( $value ) ) { $object_vars = get_object_vars( $value ); foreach ( $object_vars as $property_name => $property_value ) { $value->$property_name = map_deep_with_index( $property_value, $callback ); } } else { $value = call_user_func( $callback, $value, $index ); } return $value; } function trailingslashit( $str ) { return rtrim( $str, '/' ) . '/'; } function headerme( $str ) { $equals = str_pad( '', mb_strlen( $str ), '=' ); return PHP_EOL . PHP_EOL . $equals . PHP_EOL . $str . PHP_EOL . $equals . PHP_EOL . PHP_EOL; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0100.00716.50
8.3.50.0090.00616.35
8.3.40.0170.00320.30
8.3.30.0130.00318.84
8.3.20.0040.00424.18
8.3.10.0030.00524.66
8.3.00.0050.00326.16
8.2.180.0070.01116.50
8.2.170.0080.00822.96
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0000.00824.66
8.2.130.0090.00026.16
8.2.120.0040.00419.89
8.2.110.0030.00719.32
8.2.100.0130.00317.91
8.2.90.0030.00517.75
8.2.80.0030.00619.10
8.2.70.0080.00017.63
8.2.60.0030.00617.63
8.2.50.0000.00917.55
8.2.40.0080.00020.06
8.2.30.0050.00318.25
8.2.20.0050.00219.34
8.2.10.0180.00017.73
8.2.00.0110.00817.85
8.1.280.0100.01025.92
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00019.33
8.1.230.0040.00720.85
8.1.220.0040.00417.75
8.1.210.0040.00418.77
8.1.200.0030.00617.38
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0000.00818.59
8.1.160.0060.00319.03
8.1.150.0000.00718.56
8.1.140.0150.00317.30
8.1.130.0000.01817.43
8.1.120.0180.00017.43
8.1.110.0110.00817.55
8.1.100.0160.00217.51
8.1.90.0130.00717.52
8.1.80.0130.00417.46
8.1.70.0110.00517.43
8.1.60.0140.00617.70
8.1.50.0110.00417.69
8.1.40.0070.01117.74
8.1.30.0120.00817.71
8.1.20.0160.00017.71
8.1.10.0030.01317.52
8.1.00.0050.01017.50
8.0.300.0000.00821.52
8.0.290.0030.00616.75
8.0.280.0040.00418.54
8.0.270.0050.01016.84
8.0.260.0050.01016.88
8.0.250.0140.00316.86
8.0.240.0120.00216.82
8.0.230.0130.00316.97
8.0.220.0120.00416.91
8.0.210.0170.00016.81
8.0.200.0140.00016.93
8.0.190.0110.00316.97
8.0.180.0130.00416.86
8.0.170.0030.01016.98
8.0.160.0110.00416.83
8.0.150.0110.00616.93
8.0.140.0120.00616.86
8.0.130.0110.00416.87
8.0.120.0060.00916.78
8.0.110.0100.00316.82
8.0.100.0070.00716.74
8.0.90.0110.00516.86
8.0.80.0080.00316.91
8.0.70.0120.00816.80
8.0.60.0160.00816.76
8.0.50.0170.00016.93
8.0.30.0120.00816.87
8.0.20.0090.00916.84
8.0.10.0090.00916.81

preferences:
48.21 ms | 400 KiB | 5 Q