3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_words = ['harmony', 'Acrobat', 'harmony', 'harmony']; $array_words_unique = array_unique($array_words); //get a list of unique words from the original array $array_str = implode(",", $array_words); foreach ($array_words_unique as $word) { //count how many times the word occurs $count = substr_count($array_str, $word); //if it occurs more than once, remove the first occurence if ($count > 1) { //find the first position of the word in the string, then replace that with nothing $pos = strpos($array_str, $word); $array_str = substr_replace($array_str, "", $pos, strlen($word)); } } //convert back to an array, and filter any blank entries caused by commas with nothing between them $array_final = array_filter(explode(",", $array_str)); var_dump($array_final);

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.5.00.0130.00820.14
8.4.150.0020.00114.05
8.4.140.0150.00817.81
8.4.130.0090.01218.02
8.4.120.0100.00920.37
8.4.110.0030.00618.75
8.4.100.0100.00918.88
8.4.90.0130.00720.51
8.4.80.0100.00918.75
8.4.70.0110.00917.56
8.4.60.0120.00818.50
8.4.50.0100.01017.87
8.4.40.0180.00319.15
8.4.30.0160.00320.39
8.4.20.0070.00725.77
8.4.10.0030.00623.86
8.3.280.0140.00618.35
8.3.270.0130.00816.57
8.3.260.0110.00816.73
8.3.250.0120.00719.12
8.3.240.0120.00718.39
8.3.230.0110.00116.66
8.3.220.0050.00218.95
8.3.210.0090.01016.60
8.3.200.0030.00616.63
8.3.190.0050.00419.15
8.3.180.0130.00618.53
8.3.170.0160.00318.87
8.3.160.0070.01116.53
8.3.150.0110.00719.08
8.3.140.0100.01016.47
8.3.130.0080.00018.35
8.3.120.0090.00020.60
8.3.110.0000.01520.94
8.3.100.0090.00024.06
8.3.90.0050.00326.77
8.3.80.0060.00318.09
8.3.70.0110.00418.30
8.3.60.0060.01016.50
8.3.50.0110.00718.27
8.3.40.0090.00620.34
8.3.30.0130.00318.59
8.3.20.0060.00324.18
8.3.10.0050.00324.66
8.3.00.0030.00526.16
8.2.290.0100.01020.22
8.2.280.0120.00818.45
8.2.270.0070.01116.93
8.2.260.0000.00818.34
8.2.250.0090.00016.58
8.2.240.0050.00317.05
8.2.230.0000.00822.58
8.2.220.0100.00637.54
8.2.210.0120.00826.77
8.2.200.0090.00018.88
8.2.190.0120.00316.58
8.2.180.0090.01318.54
8.2.170.0120.00318.94
8.2.160.0070.00722.96
8.2.150.0070.00025.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00426.16
8.2.110.0000.01022.07
8.2.100.0040.00817.72
8.2.90.0000.00817.91
8.2.80.0030.00517.25
8.2.70.0060.00317.50
8.2.60.0050.00518.04
8.2.50.0080.00018.07
8.2.40.0000.00819.89
8.2.30.0030.00518.08
8.2.20.0050.00319.34
8.2.10.0070.00319.33
8.2.00.0170.00618.97
8.1.330.0100.00821.95
8.1.320.0040.00416.36
8.1.310.0040.00716.54
8.1.300.0060.01317.80
8.1.290.0000.00930.84
8.1.280.0120.00625.92
8.1.270.0060.00324.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00722.55
8.1.230.0000.01220.92
8.1.220.0050.00317.78
8.1.210.0000.00818.98
8.1.200.0060.00317.13
8.1.190.0090.00017.23
8.1.180.0080.00018.10
8.1.170.0080.00018.65
8.1.160.0040.00418.86
8.1.150.0040.00418.58
8.1.140.0000.00722.58
8.1.130.0110.01018.66
8.1.120.0120.00818.55
8.1.110.0150.00418.74
8.1.100.0110.00618.53
8.1.90.0120.00918.63
8.1.80.0160.00318.59
8.1.70.0140.00618.73
8.1.60.0180.00618.82
8.1.50.0120.00918.72
8.1.40.0190.00618.84
8.1.30.0200.00318.90
8.1.20.0170.00618.85
8.1.10.0220.00418.74
8.1.00.0190.00518.71
8.0.300.0030.00519.98
8.0.290.0040.00416.75
8.0.280.0030.00318.46
8.0.270.0060.01318.02
8.0.260.0060.00618.07
8.0.250.0130.00218.17
8.0.240.0060.00817.99
8.0.230.0060.00617.96
8.0.220.0130.00317.93
8.0.210.0110.00317.97
8.0.200.0090.00518.08
8.0.190.0060.00618.14
8.0.180.0080.00817.95
8.0.170.0120.00018.00
8.0.160.0160.00018.08
8.0.150.0140.00017.98
8.0.140.0100.00317.76
8.0.130.0100.00618.00
8.0.120.0070.00717.93
8.0.110.0120.00017.93
8.0.100.0040.01218.01
8.0.90.0150.00517.89
8.0.80.0140.00318.04
8.0.70.0090.00417.95
8.0.60.0130.00318.05
8.0.50.0130.00318.02
8.0.30.0140.00717.98
8.0.20.0150.00317.97
8.0.10.0110.00518.01

preferences:
30.75 ms | 403 KiB | 5 Q