3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace efiku; class Book { private $name; private $author; private $codeNumber; /** * Book constructor. * @param string $name * @param string $author * @param int $codeNumber */ public function __construct(string $name, string $author, int $codeNumber) { $this->name = $name; $this->author = $author; $this->codeNumber = $codeNumber; } /** * @return string */ public function getName() : string { return $this->name; } /** * @return string */ public function getAuthor() : string { return $this->author; } /** * @return int */ public function getCodeNumber() : int { return $this->codeNumber; } public function __toString() { return $this->name . " --- " . $this->author . " --- " . $this->codeNumber; } } use efiku\Book; $arrayOfBooks = []; // Generowanie tablicy z książkami foreach (range(1, 20) as $number) { $arrayOfBooks["book.{$number}"] = new Book( "PHP {$number}", "Podręcznik profesjonalisty! wydanie:{$number}", mt_rand(1, $number + 1 * 3) ); } // Sortujemy z użyciem wbudowanego mechanizmu asort($arrayOfBooks); foreach ($arrayOfBooks as $book) { echo $book . PHP_EOL; } ///////////////////////////////////////////////////// echo "\nSORTUJEMY Według Naszego mechanizmu\n\n"; uasort($arrayOfBooks, function (Book $first, Book $second) { $firstEditionNumber = (int)substr(strrchr($first->getAuthor(), ":"), 1); $secondEditionNumber = (int)substr(strrchr($second->getAuthor(), ":"), 1); return $firstEditionNumber <=> $secondEditionNumber; }); foreach ($arrayOfBooks as $book) { echo $book . 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.0.110.0000.00816.98
8.0.100.0040.00416.94
8.0.90.0000.00817.05
8.0.80.0110.00416.87
8.0.70.0060.00316.86
8.0.60.0030.00616.86
8.0.50.0000.00716.83
8.0.30.0090.00917.15
8.0.20.0100.00917.40
8.0.10.0000.00916.96
8.0.00.0100.01016.77
7.4.240.0020.00516.50
7.4.230.0030.00516.61
7.4.220.0110.00716.40
7.4.210.0120.00616.52
7.4.200.0030.00316.58
7.4.160.0180.00016.46
7.4.150.0090.00917.40
7.4.140.0100.01017.86
7.4.130.0140.00616.41
7.4.120.0070.01016.61
7.4.110.0140.00716.59
7.4.100.0100.00716.67
7.4.90.0040.01316.58
7.4.80.0140.01119.39
7.4.70.0030.01416.62
7.4.60.0130.00316.52
7.4.50.0140.00316.45
7.4.40.0130.00316.40
7.4.30.0110.00616.73
7.4.00.0070.00815.00
7.3.300.0070.00016.34
7.3.290.0000.00716.25
7.3.280.0040.01216.39
7.3.270.0190.00417.40
7.3.260.0110.01516.52
7.3.240.0160.00616.34
7.3.230.0150.00616.60
7.3.210.0100.00716.42
7.3.200.0140.00616.51
7.3.190.0120.00616.43
7.3.180.0130.00416.47
7.3.170.0150.00416.48
7.3.160.0090.00916.43
7.3.120.0130.00715.15
7.3.110.0120.00914.72
7.3.100.0080.00614.82
7.3.90.0070.00714.61
7.3.80.0040.01114.96
7.3.70.0080.00814.86
7.3.60.0030.00715.02
7.3.50.0090.00314.94
7.3.40.0040.01114.80
7.3.30.0090.00314.73
7.3.20.0060.00916.64
7.3.10.0100.00516.67
7.3.00.0030.00816.24
7.2.330.0120.00616.78
7.2.320.0150.00416.56
7.2.310.0090.00816.78
7.2.300.0030.01416.77
7.2.290.0060.01216.73
7.2.250.0070.01115.09
7.2.240.0030.01315.37
7.2.230.0070.01015.34
7.2.220.0000.01215.11
7.2.210.0040.00815.21
7.2.200.0000.01614.99
7.2.190.0030.01415.09
7.2.180.0030.00915.30
7.2.170.0070.01115.08
7.2.130.0030.00916.65
7.2.120.0130.00316.56
7.2.110.0090.00616.64
7.2.100.0160.00516.77
7.2.90.0100.01316.68
7.2.80.0130.01016.59
7.2.70.0140.01016.89
7.2.60.0080.00816.82
7.2.50.0000.01816.52
7.2.40.0070.00716.85
7.2.30.0060.00916.66
7.2.20.0070.01116.83
7.2.10.0070.01316.83
7.2.00.0090.00617.95
7.1.330.0040.01116.01
7.1.320.0040.01215.94
7.1.310.0030.00715.98
7.1.300.0030.00915.93
7.1.290.0070.00315.63
7.1.280.0070.00715.63
7.1.270.0070.00715.69
7.1.260.0070.00315.55
7.1.250.0080.00515.63
7.1.200.0040.00716.00
7.1.100.0070.01418.25
7.1.70.0000.00816.91
7.1.60.0060.01819.28
7.1.50.0130.00316.71
7.1.00.0000.08022.54
7.0.200.0000.01116.43
7.0.60.0030.05321.71
7.0.50.0070.05717.95
7.0.40.0130.08020.22
7.0.30.0170.07020.24
7.0.20.0230.05320.12
7.0.10.0030.05720.06
7.0.00.0030.08020.20
5.6.280.0000.05021.03
5.6.210.0070.07320.48
5.6.200.0000.05318.15
5.6.190.0070.05020.53
5.6.180.0330.07320.64
5.6.170.0300.08320.62
5.6.160.0100.05320.57
5.6.150.0100.06018.19
5.6.140.0070.07018.28
5.6.130.0130.07718.18
5.6.120.0070.04021.13
5.6.110.0030.09021.01
5.6.100.0000.08720.89
5.6.90.0100.07720.98
5.6.80.0030.07320.29
5.5.350.3800.03720.44
5.5.340.0030.03718.07
5.5.330.0070.07320.43
5.5.320.0170.08020.33
5.5.310.0200.04720.56
5.5.300.0030.04717.95
5.5.290.0030.04018.04
5.5.280.0070.08720.88
5.5.270.0030.08720.73
5.5.260.0170.07720.73
5.5.250.0170.07720.72
5.5.240.0200.06720.16

preferences:
43.02 ms | 401 KiB | 5 Q