3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( // Sub-array 1 array ( // Story 'Monkey 1' - Has identical sub-sub-arrays 'Monkey 2' and 'Monkey 3' and will be merged with them. array ( "header" => "This is a story about a monkey.", 'keywords' => array( "Trees", "Monkey", "Flying", "Drink", "Vacation", "Coconut", "Big", "Bonobo", "Climbing") ), // Story 'Cat 1' - Has identical sub-sub-array 'Cat 2' and will be merged with it. array ( "header" => "Here's a catarific story about a cat", 'keywords' => array( "meauw", "raaaw", "kitty", "growup", "Fun", "claws", "fish", "salmon") ) ), // Sub-array 2 array ( // Story 'Monkey 2' - Has identical sub-sub-arrays 'Monkey 1' and 'Monkey 3' and will be merged with them. array ( "header" => "This is another, but different story, about a monkey.", 'keywords' => array( "Monkey", "Big", "Trees", "Bonobo", "Fun", "Dance", "Cow", "Coconuts") ), // Story 'Cat 2' - Has identical sub-sub-array 'Cat 1' and will be merged with it. array ( "header" => "Here's a different story about a cat", 'keywords' => array( "meauwe", "ball", "cat", "kitten", "claws", "sleep", "fish", "purr") ) ), // Sub-array 3 array ( // Story 'Monkey 3' - Has identical sub-sub-arrays 'Monkey 1' and 'Monkey 2' and will be merged with them. array ( "header" => "This is a third story about a monkey.", 'keywords' => array( "Jungle", "tree", "monkey", "Bonobo", "Fun", "Dance", "climbing", "Coconut", "pretty") ), // Story 'Fireman 1' - Has no identical sub-sub-arrays and will not be merged. array ( "header" => "This is a story about a fireman", 'keywords' => array( "fire", "explosion", "burning", "rescue", "happy", "help", "water", "car") ) ) ); $new =[]; foreach($array as $subarr){ $new = array_merge($new, $subarr); } var_dump($new); foreach($new as $key => $story){ $words = "/" . implode("|", $story["keywords"]) . "/i"; foreach($new as $key2 => $story2){ if($key != $key2 && $key2 > $key && !in_array($key2, $merged)){ if(count(preg_grep($words, $story2["keywords"])) >1){ echo $key . " " . $key2 . "\n"; echo $story["header"] . " = " . $story2["header"] ."\n\n"; $res[$key] = ["header" => [$story["header"], $story2["header"]], "keywords" => array_merge($story["keywords"], $story2["keywords"])]; $merged[] = $key2; } } } } //var_dump($res);

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.0150.00618.66
8.3.50.0100.01016.22
8.3.40.0000.01718.87
8.3.30.0130.00318.71
8.3.20.0050.00319.20
8.3.10.0060.00320.98
8.3.00.0080.00019.66
8.2.180.0030.01318.41
8.2.170.0080.01522.96
8.2.160.0120.00319.08
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00819.72
8.2.120.0040.00426.35
8.2.110.0060.00322.13
8.2.100.0070.00617.82
8.2.90.0060.00320.53
8.2.80.0080.00019.34
8.2.70.0040.00417.93
8.2.60.0030.00718.05
8.2.50.0040.00418.10
8.2.40.0030.00519.30
8.2.30.0030.00619.45
8.2.20.0030.00618.10
8.2.10.0050.00218.25
8.2.00.0060.00321.16
8.1.280.0170.00025.92
8.1.270.0080.00023.91
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00620.82
8.1.230.0040.00722.62
8.1.220.0090.00017.79
8.1.210.0000.00819.04
8.1.200.0080.00017.35
8.1.190.0030.00617.35
8.1.180.0060.00318.10
8.1.170.0040.00418.55
8.1.160.0080.00020.68
8.1.150.0000.00718.95
8.1.140.0040.00417.71
8.1.130.0030.00318.93
8.1.120.0030.00717.52
8.1.110.0040.00417.36
8.1.100.0000.00717.52
8.1.90.0080.00017.45
8.1.80.0080.00017.46
8.1.70.0050.00317.47
8.1.60.0040.00417.60
8.1.50.0000.00817.56
8.1.40.0000.00817.52
8.1.30.0000.00817.56
8.1.20.0030.00517.67
8.1.10.0030.00517.52
8.1.00.0030.00617.52
8.0.300.0050.00220.04
8.0.290.0040.00416.75
8.0.280.0030.00418.55
8.0.270.0030.00317.27
8.0.260.0070.00017.15
8.0.250.0040.00416.99
8.0.240.0030.00617.05
8.0.230.0070.00017.05
8.0.220.0000.00716.98
8.0.210.0000.00717.00
8.0.200.0000.00816.92
8.0.190.0090.00016.96
8.0.180.0000.00916.98
8.0.170.0030.00617.04
8.0.160.0020.00517.06
8.0.150.0050.00216.91
8.0.140.0070.00017.00
8.0.130.0060.00013.36
8.0.120.0000.00716.95
8.0.110.0000.00816.94
8.0.100.0000.00716.81
8.0.90.0000.00717.01
8.0.80.0060.01116.96
8.0.70.0000.00816.75
8.0.60.0060.00316.84
8.0.50.0040.00417.03
8.0.30.0080.01217.05
8.0.20.0130.00717.40
8.0.10.0000.00717.11
8.0.00.0100.01016.92
7.4.330.0000.00515.55
7.4.320.0000.00716.85
7.4.300.0000.00716.77
7.4.290.0040.00416.72
7.4.280.0040.00416.84
7.4.270.0090.00016.75
7.4.260.0070.00016.63
7.4.250.0040.00416.71
7.4.240.0040.00416.84
7.4.230.0070.00016.68
7.4.220.0050.00316.64
7.4.210.0100.00616.75
7.4.200.0000.00716.78
7.4.160.0120.00816.74
7.4.140.0130.01117.86
7.4.130.0110.01116.94
7.4.120.0100.01216.83
7.4.110.0070.01416.95
7.4.100.0100.01616.93
7.4.90.0120.01616.91
7.4.80.0140.00519.39
7.4.70.0090.00916.65
7.4.60.0130.01016.54
7.4.50.0110.00416.69
7.4.40.0130.01316.80
7.4.00.0040.01115.43
7.3.330.0050.00013.45
7.3.320.0040.00413.28
7.3.310.0000.00716.34
7.3.300.0030.00516.48
7.3.290.0070.00016.62
7.3.280.0050.01116.54
7.3.260.0140.00716.66
7.3.240.0140.00716.61
7.3.230.0120.00816.75
7.3.210.0110.01116.52
7.3.200.0060.01316.61
7.3.190.0160.00316.68
7.3.180.0100.01316.88
7.3.170.0070.01116.66
7.3.160.0110.01117.03
7.2.330.0030.01816.70
7.2.320.0120.00616.89
7.2.310.0120.01216.80
7.2.300.0110.01116.84
7.2.290.0100.01616.81
7.2.60.0840.01215.07
7.2.50.0820.01315.11
7.2.40.1110.01315.57
7.2.30.0920.01215.70
7.2.20.0980.00915.66
7.2.10.1440.01015.86
7.2.00.0860.01015.52
7.1.200.0030.01015.70
7.1.170.0870.01314.23
7.1.160.1070.01117.38
7.1.150.0990.01417.39
7.1.140.0840.00817.26
7.1.130.0830.01117.31
7.1.120.0710.01317.21
7.1.110.0840.01116.89
7.1.100.0980.01416.42
7.1.90.0140.01316.29
7.1.80.0150.01316.39
7.1.70.1150.01215.77
7.1.60.1230.01733.64
7.1.50.1380.01533.14
7.1.40.0370.01732.81
7.1.30.1040.01932.94
7.1.20.0910.01733.00
7.1.10.0930.01115.06
7.1.00.1030.01515.16

preferences:
41.94 ms | 401 KiB | 5 Q