3v4l.org

run code in 300+ PHP versions simultaneously
<?php mt_srand( 1234 ); // Arrange $input = []; for ($i = 0; $i < 10; $i++ ) { $input[] = wfRandomString( 5 ); } // Act $map = []; foreach ( $input as $str ) { $map[$str] = 'something computed something'; } $output = []; foreach ( $map as $str => $somthing ) { $output[] = $str; } // Assert foreach ( $output as $str ) { if ( !is_string( $str ) ) { echo "WAT: "; var_dump( $str ); } else { echo "OK: "; var_dump( $str ); } } echo json_encode( $output, JSON_PRETTY_PRINT ); // ------- /** From MediaWiki 1.35 - https://w.wiki/oyY */ function wfRandomString( $length ) : string { $str = ''; for ( $n = 0; $n < $length; $n += 7 ) { $str .= sprintf( '%07x', mt_rand() & 0xfffffff ); } return substr( $str, 0, $length ); }

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.0.00.0140.00516.92
7.4.130.0110.00716.50
7.4.120.0080.01616.57
7.4.110.0120.01216.50
7.4.100.0150.00716.59
7.4.90.0150.00816.54
7.4.80.0220.00016.39
7.4.70.0070.01816.23
7.4.60.0110.00816.52
7.4.50.0120.00916.31
7.4.40.0030.01616.40
7.4.30.0140.01116.38
7.4.20.0130.00516.36
7.4.10.0070.01116.59
7.4.00.0160.00716.44
7.3.250.0100.01016.59
7.3.240.0100.01816.21
7.3.230.0130.01216.64
7.3.220.0130.00616.43
7.3.210.0110.01116.33
7.3.200.0070.01716.44
7.3.190.0120.01216.61
7.3.180.0090.01516.41
7.3.170.0170.00316.40
7.3.160.0030.01616.41
7.3.150.0170.00716.38
7.3.140.0170.00316.39
7.3.130.0090.01416.57
7.3.120.0190.00416.33
7.3.110.0150.00716.59
7.3.100.0140.00316.39
7.3.90.0130.01016.51
7.3.80.0100.01016.44
7.3.70.0140.00716.34
7.3.60.0060.01316.58
7.3.50.0120.00616.45
7.3.40.0130.00516.47
7.3.30.0150.00716.46
7.3.20.0140.00716.33
7.3.10.0170.00616.41
7.3.00.0160.00316.43

preferences:
39.1 ms | 400 KiB | 5 Q