3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mysql_result[0]['id']="1"; $mysql_result[0]['address']="www.example.com/page1"; $mysql_result[0]['title']="Page 1"; $mysql_result[0]['content']="The quick dog jumps over the lazy dog."; $mysql_result[0]['image']="image1.jpg"; $mysql_result[1]['id']="2"; $mysql_result[1]['address']="www.example.com/page2"; $mysql_result[1]['title']="Page 2"; $mysql_result[1]['content']="The best thing about morning is breakfast."; $mysql_result[1]['image']="image2.jpg"; $mysql_result[2]['id']="3"; $mysql_result[2]['address']="www.example.com/page3"; $mysql_result[2]['title']="Page 3"; $mysql_result[2]['content']="Hotdogs are great ballpark food."; $mysql_result[2]['image']="image3.jpg"; // instead of the above initialization which i made by hand for demonstration, // you need to initialize the variable $mysql_result with data // from your DB like this // // $inc = 0; // while($results = $result->fetch_array(MYSQLI_ASSOC)) // { // $mysql_result[$inc]=$results; // $inc++; // } $query="dog"; $chars_to_show_before = 10; // ...1234567890dog $chars_to_show_after = 10; // dog1234567890... foreach($mysql_result as $results) { $content = str_replace($query,"my_un1qu3_r3pl4c3m3nt_".$query,$results['content']); $occurences = explode("my_un1qu3_r3pl4c3m3nt_",$content); $position_in_original_content = 0; foreach($occurences as $an_occurence) { if (strpos($an_occurence,$query) !== false) { $content=$an_occurence; echo '<li class="media"> <a class="pull-left" href="'.$results['address'].'"> <img class="media-object thumbnail" src="'.$results['image'].'" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="'.$results['address'].'">'.$results['title'].'</a></h4> <p>...'.str_replace($query,'<strong>'.$query.'</strong>', substr($results['content'],max(0,($position_in_original_content-$chars_to_show_before)),strlen(strlen($query))+$chars_to_show_after+$chars_to_show_before)).'...</p> </div> </li>'; } $position_in_original_content = $position_in_original_content + strlen($an_occurence); } } ?>

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.0140.00418.55
8.3.50.0070.01221.89
8.3.40.0120.00618.92
8.3.30.0070.00719.22
8.3.20.0040.00420.21
8.3.10.0040.00423.46
8.3.00.0080.00022.52
8.2.180.0140.00725.92
8.2.170.0110.00422.96
8.2.160.0090.00622.13
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0050.00322.16
8.2.110.0100.00020.94
8.2.100.0040.00817.83
8.2.90.0060.00317.84
8.2.80.0000.00818.05
8.2.70.0080.00018.03
8.2.60.0060.00318.34
8.2.50.0000.00818.10
8.2.40.0000.00819.46
8.2.30.0030.00618.22
8.2.20.0000.00717.75
8.2.10.0050.00319.58
8.2.00.0000.00717.77
8.1.280.0140.00725.92
8.1.270.0030.00523.88
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0090.00023.89
8.1.230.0090.00322.66
8.1.220.0000.01017.91
8.1.210.0000.00918.77
8.1.200.0100.00017.38
8.1.190.0050.00517.23
8.1.180.0030.00518.10
8.1.170.0000.00818.51
8.1.160.0060.00318.91
8.1.150.0080.00018.55
8.1.140.0000.00817.54
8.1.130.0050.00217.73
8.1.120.0040.00417.41
8.1.110.0040.00417.52
8.1.100.0000.00717.45
8.1.90.0030.00717.42
8.1.80.0030.00317.45
8.1.70.0000.00817.42
8.1.60.0050.00317.50
8.1.50.0030.00617.56
8.1.40.0070.00017.55
8.1.30.0000.00817.60
8.1.20.0040.00417.56
8.1.10.0000.00817.49
8.1.00.0050.00217.43
8.0.300.0080.00019.63
8.0.290.0040.00416.88
8.0.280.0030.00318.45
8.0.270.0090.00017.21
8.0.260.0000.00716.86
8.0.250.0030.00316.84
8.0.240.0000.00717.05
8.0.230.0070.00017.00
8.0.220.0070.00016.97
8.0.210.0090.00016.97
8.0.200.0060.00316.96
8.0.190.0040.00416.99
8.0.180.0000.00716.96
8.0.170.0000.00817.00
8.0.160.0070.00016.87
8.0.150.0040.00416.83
8.0.140.0040.00416.88
8.0.130.0050.00013.34
8.0.120.0000.00816.88
8.0.110.0040.00416.85
8.0.100.0020.00516.88
8.0.90.0000.00816.98
8.0.80.0100.00716.93
8.0.70.0080.00016.80
8.0.60.0000.00717.03
8.0.50.0050.00216.97
8.0.30.0120.01217.03
8.0.20.0110.01017.40
8.0.10.0040.00417.07
8.0.00.0080.01116.84
7.4.330.0000.00615.14
7.4.320.0040.00416.47
7.4.300.0060.00316.70
7.4.290.0040.00416.61
7.4.280.0000.00716.54
7.4.270.0030.00616.57
7.4.260.0050.00216.64
7.4.250.0070.00016.64
7.4.240.0000.00716.62
7.4.230.0030.00316.58
7.4.220.0030.00316.67
7.4.210.0120.00316.55
7.4.200.0040.00416.63
7.4.190.0000.00716.46
7.4.160.0080.00816.70
7.4.150.0130.00417.40
7.4.140.0090.00917.86
7.4.130.0120.00516.53
7.4.120.0050.01516.50
7.4.110.0070.01016.46
7.4.100.0110.00816.51
7.4.90.0430.00516.59
7.4.80.0100.01219.39
7.4.70.0060.01016.66
7.4.60.0030.01316.59
7.4.50.0000.00516.65
7.4.40.0060.00922.77
7.4.30.0100.00716.60
7.4.10.0070.01114.94
7.4.00.0100.00514.81
7.3.330.0000.00713.04
7.3.320.0030.00313.27
7.3.310.0070.00016.23
7.3.300.0000.00616.26
7.3.290.0060.00916.39
7.3.280.0090.01116.32
7.3.270.0100.00717.40
7.3.260.0110.01116.44
7.3.250.0070.01116.56
7.3.240.0110.00816.55
7.3.230.0100.00616.65
7.3.210.0130.00316.46
7.3.200.0140.00919.39
7.3.190.0150.00916.44
7.3.180.0130.00316.48
7.3.170.0060.01216.37
7.3.160.0110.00416.38
7.3.130.0100.01014.81
7.3.120.0100.00714.90
7.3.110.0060.01214.68
7.3.100.0030.01214.83
7.3.90.0070.01014.90
7.3.80.0040.01014.77
7.3.70.0090.00714.69
7.3.60.0050.01114.75
7.3.50.0030.00614.78
7.3.40.0060.00714.77
7.3.30.0060.00714.85
7.3.20.0080.00916.62
7.3.10.0090.00516.50
7.3.00.0090.00516.75
7.2.330.0060.01216.82
7.2.320.0090.00616.53
7.2.310.0110.00816.85
7.2.300.0000.01816.66
7.2.290.0080.00816.64
7.2.260.0070.01115.35
7.2.250.0080.01015.14
7.2.240.0020.01215.10
7.2.230.0060.01114.88
7.2.220.0070.00915.06
7.2.210.0080.00615.11
7.2.200.0050.00915.11
7.2.190.0060.00814.87
7.2.180.0060.00615.07
7.2.170.0050.00915.02
7.2.160.0070.00714.90
7.2.150.0090.00916.93
7.2.140.0080.00416.92
7.2.130.0040.01116.91
7.2.120.0090.00617.04
7.2.110.0000.00916.94
7.2.100.0080.00817.02
7.2.90.0070.00717.02
7.2.80.0030.01016.92
7.2.70.0070.01017.05
7.2.60.0020.01116.93
7.2.50.0040.01216.89
7.2.40.0030.00917.06
7.2.30.0120.00317.06
7.2.20.0060.00617.17
7.2.10.0030.00916.80
7.2.00.0010.01118.16
7.1.330.0030.01215.87
7.1.320.0080.00915.62
7.1.310.0050.00715.63
7.1.300.0070.00915.74
7.1.290.0040.01115.83
7.1.280.0100.00515.86
7.1.270.0040.01015.59
7.1.260.0030.00915.78
7.1.250.0030.00915.61
7.1.240.0000.01315.80
7.1.230.0100.00015.99
7.1.220.0040.01115.93
7.1.210.0030.01415.63
7.1.200.0100.00415.58
7.1.190.0030.00815.76
7.1.180.0090.00015.75
7.1.170.0040.00715.71
7.1.160.0000.01415.74
7.1.150.0070.00715.81
7.1.140.0000.01215.62
7.1.130.0060.00615.86
7.1.120.0060.00615.66
7.1.110.0030.01115.93
7.1.100.0020.01216.91
7.1.90.0030.01015.93
7.1.80.0090.00415.89
7.1.70.0030.00716.37
7.1.60.0060.01117.67
7.1.50.0070.00916.27
7.1.40.0090.00615.86
7.1.30.0000.01115.54
7.1.20.0040.00715.82
7.1.10.0030.00715.73
7.1.00.0050.04019.19
7.0.330.0040.01115.41
7.0.320.0060.00315.49
7.0.310.0060.00615.22
7.0.300.0050.00515.56
7.0.290.0030.00915.65
7.0.280.0040.01415.45
7.0.270.0060.00615.41
7.0.260.0040.00915.28
7.0.250.0040.00415.47
7.0.240.0060.00615.23
7.0.230.0080.00015.43
7.0.220.0070.00715.34
7.0.210.0040.00815.47
7.0.200.0020.00916.05
7.0.190.0040.00415.26
7.0.180.0000.01015.45
7.0.170.0030.01215.50
7.0.160.0040.00815.52
7.0.150.0040.00415.53
7.0.140.0050.04018.61
7.0.130.0060.00615.49
7.0.120.0030.00915.59
7.0.110.0060.00615.43
7.0.100.0030.01415.49
7.0.90.0030.00815.54
7.0.80.0100.00315.56
7.0.70.0060.00315.40
7.0.60.0050.04618.65
7.0.50.0050.04716.69
7.0.40.0050.02716.71
7.0.30.0130.02516.66
7.0.20.0210.03916.77
7.0.10.0030.02816.87
7.0.00.0120.02816.98
5.6.400.0060.00614.13
5.6.390.0090.00614.38
5.6.380.0070.00714.34
5.6.370.0000.01214.24
5.6.360.0060.00614.71
5.6.350.0060.00614.71
5.6.340.0000.01014.38
5.6.330.0030.00914.77
5.6.320.0000.01214.49
5.6.310.0000.01514.43
5.6.300.0070.00714.63
5.6.290.0060.00814.45
5.6.280.0060.03617.74
5.6.270.0120.00314.61
5.6.260.0030.00714.47
5.6.250.0080.00414.20
5.6.240.0070.00714.55
5.6.230.0080.00314.51
5.6.220.0030.01414.48
5.6.210.0050.04517.55
5.6.200.0050.02716.38
5.6.190.0080.04217.44
5.6.180.0130.04317.53
5.6.170.0150.03817.54
5.6.160.0080.02317.60
5.6.150.0070.02216.29
5.6.140.0050.04016.31
5.6.130.0080.02516.43
5.6.120.0050.04517.72
5.6.110.0060.04317.68
5.6.100.0070.05217.79
5.6.90.0070.03717.68
5.6.80.0020.04517.34
5.6.70.0060.00614.16
5.6.60.0030.00914.56
5.6.50.0090.00614.50
5.6.40.0040.00814.43
5.6.30.0030.01014.30
5.6.20.0000.01714.39
5.6.10.0000.00914.22
5.6.00.0110.00314.49
5.5.380.0070.00414.42
5.5.370.0070.00714.63
5.5.360.0060.01214.40
5.5.350.2070.02517.22
5.5.340.0050.02716.12
5.5.330.0030.04017.21
5.5.320.0290.02517.34
5.5.310.0220.04217.31
5.5.300.0030.03516.13
5.5.290.0050.03416.16
5.5.280.0100.04217.49
5.5.270.0080.04317.62
5.5.260.0130.03517.47
5.5.250.0020.02817.58
5.5.240.0150.04017.26
5.5.230.0080.00414.31
5.5.220.0070.00714.38
5.5.210.0090.00614.09
5.5.200.0060.00614.20
5.5.190.0000.00814.46
5.5.180.0070.00714.38
5.5.170.0070.00714.58
5.5.160.0070.00314.29
5.5.150.0080.00514.22
5.5.140.0090.00614.29
5.5.130.0030.00614.72
5.5.120.0080.00314.31
5.5.110.0000.01114.36
5.5.100.0100.00314.13
5.5.90.0080.00014.05
5.5.80.0080.00414.53
5.5.70.0060.00914.24
5.5.60.0070.01014.37
5.5.50.0000.00914.32
5.5.40.0030.00714.46
5.5.30.0030.01314.10
5.5.20.0000.01614.55
5.5.10.0070.00414.58
5.5.00.0070.00714.20
5.4.450.0050.02715.38
5.4.440.0030.02715.33
5.4.430.0070.02515.27
5.4.420.0080.02315.29
5.4.410.0030.02315.25
5.4.400.0070.03714.96
5.4.390.0070.03515.00
5.4.380.0050.02315.13
5.4.370.0060.02514.90
5.4.360.0010.02614.92
5.4.350.0020.04715.04
5.4.340.0100.02214.98
5.4.330.0000.01111.06
5.4.320.0070.04015.15
5.4.310.0050.04314.99
5.4.300.0040.02114.92
5.4.290.0010.02415.00
5.4.280.0100.02315.18
5.4.270.0030.02814.94
5.4.260.0020.04415.13
5.4.250.0050.04115.13
5.4.240.0040.02914.99
5.4.230.0060.02115.07
5.4.220.0070.02415.13
5.4.210.0060.03514.95
5.4.200.0030.03314.97
5.4.190.0100.03215.02
5.4.180.0090.02515.09
5.4.170.0050.02315.09
5.4.160.0010.04415.09
5.4.150.0030.02514.91
5.4.140.0020.02713.68
5.4.130.0080.03613.64
5.4.120.0090.03013.64
5.4.110.0070.03513.73
5.4.100.0050.03113.59
5.4.90.0090.03813.74
5.4.80.0070.03713.72
5.4.70.0070.03513.81
5.4.60.0030.04213.77
5.4.50.0020.04513.72
5.4.40.0080.02713.68
5.4.30.0050.03413.69
5.4.20.0050.03613.54
5.4.10.0020.02913.62
5.4.00.0020.03313.31
5.3.290.0100.05314.78
5.3.280.0100.05014.54
5.3.270.0070.05314.46
5.3.260.0070.03714.44
5.3.250.0030.05314.60
5.3.240.0070.04314.57
5.3.230.0070.07314.51
5.3.220.0000.05714.54
5.3.210.0030.08314.51
5.3.200.0070.03714.60
5.3.190.0100.07714.52
5.3.180.0070.06314.50
5.3.170.0070.03714.46
5.3.160.0030.07714.40
5.3.150.0100.05014.60
5.3.140.0070.07014.48
5.3.130.0000.05014.52
5.3.120.0100.06714.58
5.3.110.0070.06714.49
5.3.100.0130.05313.98
5.3.90.0070.07013.96
5.3.80.0130.06313.98
5.3.70.0030.06313.98
5.3.60.0030.07013.99
5.3.50.0000.05313.79
5.3.40.0070.08013.91
5.3.30.0100.07013.86
5.3.20.0070.05313.64
5.3.10.0030.03713.63
5.3.00.0100.06713.48
5.2.170.0030.06711.10
5.2.160.0030.03011.34
5.2.150.0100.05311.33
5.2.140.0030.07011.16
5.2.130.0070.03311.12
5.2.120.0070.03011.13
5.2.110.0100.05311.07
5.2.100.0070.03711.20
5.2.90.0030.02711.10
5.2.80.0030.04311.06
5.2.70.0130.06011.00
5.2.60.0130.05711.15
5.2.50.0000.07011.03
5.2.40.0000.06311.00
5.2.30.0070.04711.00
5.2.20.0070.03311.00
5.2.10.0100.05311.00
5.2.00.0030.06011.00
5.1.60.0030.04311.00
5.1.50.0030.04311.00
5.1.40.0100.04011.00
5.1.30.0130.03311.00
5.1.20.0030.04311.00
5.1.10.0000.03011.00
5.1.00.0000.03711.00
5.0.50.0070.03711.00
5.0.40.0000.02311.00
5.0.30.0000.06011.00
5.0.20.0030.04311.00
5.0.10.0000.03011.00
5.0.00.0000.03311.00
4.4.90.0000.01711.00
4.4.80.0030.01311.00
4.4.70.0000.03711.00
4.4.60.0030.01711.00
4.4.50.0030.04011.00
4.4.40.0000.05711.00
4.4.30.0070.02011.00
4.4.20.0070.01311.00
4.4.10.0030.03311.00
4.4.00.0000.03011.00
4.3.110.0000.04011.00
4.3.100.0030.03311.00
4.3.90.0000.02011.00
4.3.80.0000.04011.00
4.3.70.0000.01711.00
4.3.60.0070.03311.00
4.3.50.0000.02011.00
4.3.40.0000.02711.00
4.3.30.0000.01711.00
4.3.20.0100.02711.00
4.3.10.0000.03711.00
4.3.00.0000.03711.00

preferences:
51.56 ms | 401 KiB | 5 Q