3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values=[ ["id"=> 0,"dn"=> "OU=Microsoft Exchange Security Groups,DC=local,DC=com"], ["id"=> 1,"dn"=> "OU=Domain Controllers,DC=local,DC=com"], ["id"=> 2,"dn"=> "OU=DIT,OU=DVIOU,DC=local,DC=com"], ["id"=> 3,"dn"=> "OU=Service Accounts,DC=local,DC=com"], ["id"=> 4,"dn"=> "OU=STT,OU=DIT,OU=DVIOU,DC=local,DC=com"], ["id"=> 5,"dn"=> "OU=STX,OU=DIT,OU=DVIOU,DC=local,DC=com"], ["id"=> 6,"dn"=> "OU=DVIOU,DC=local,DC=com"], ["id"=> 7,"dn"=> "OU=DPW,OU=DVIOU,DC=local,DC=com"], ["id"=> 8,"dn"=> "OU=STT,OU=DPW,OU=DVIOU,DC=local,DC=com"], ["id"=> 9,"dn"=> "OU=OLG,OU=DVIOU,DC=local,DC=com"], ["id"=> 10,"dn"=> "OU=DIT_Consultants,OU=DIT,OU=DVIOU,DC=local,DC=com"], ["id"=> 11,"dn"=> "OU=911,OU=DVIOU,DC=local,DC=com"], ["id"=> 12,"dn"=> "OU=Users,OU=911,OU=DVIOU,DC=local,DC=com"], ["id"=> 13,"dn"=> "OU=PERB,OU=DVIOU,DC=local,DC=com"], ["id"=> 14,"dn"=> "OU=STX,OU=PERB,OU=DVIOU,DC=local,DC=com"] ]; //Let's make dictionary foreach($values as $val){ //Find all OU preg_match_all('/OU=([^,]+)/',$val['dn'],$m); //print_r($m); $name=$m[1][0]; //Add elements to array $val=array_merge($val,[ 'name'=>$name, 'parent'=>0, //This will be done later 'level'=>count($m[1]), 'parent_name'=>$m[1][1] ?? '', ]); $dict[$name]=$val; } print_r($dict); //Let's get parent IDs from dictionary by name foreach($dict as &$val) $val['parent']=$dict[$val['parent_name']]['id'] ?? 0; print_r($dict); //Remove keys $result=array_values($dict); //Sort by IDs sort($result); print_r($result);

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.21
8.4.150.0010.00014.05
8.4.140.0110.01317.66
8.4.130.0060.00418.16
8.4.120.0120.00820.25
8.4.110.0110.00522.44
8.4.100.0080.00318.04
8.4.90.0130.00819.57
8.4.80.0190.00819.80
8.4.70.0150.01119.72
8.4.60.0400.00817.75
8.4.50.0210.00618.19
8.4.40.0280.00317.57
8.4.30.0400.01217.54
8.4.20.0400.00817.46
8.4.10.0360.00717.65
8.3.280.0130.00818.67
8.3.270.0200.00916.88
8.3.260.0120.00816.88
8.3.250.0030.00519.16
8.3.240.0120.00916.91
8.3.230.0120.00716.88
8.3.220.0190.00616.97
8.3.210.0240.00516.97
8.3.200.0380.00216.97
8.3.190.0320.00716.97
8.3.180.0350.00916.97
8.3.170.0340.00616.97
8.3.160.0350.00716.97
8.3.150.0400.00616.97
8.3.140.0410.01016.97
8.3.130.0340.00617.03
8.3.120.0340.01016.97
8.3.110.0200.00516.97
8.3.100.0350.01016.97
8.3.90.0210.00517.01
8.3.80.0300.00616.97
8.3.70.0250.00116.97
8.3.60.0430.00916.97
8.3.50.0390.01016.97
8.3.40.0380.01017.49
8.3.30.0270.00817.80
8.3.20.0220.00617.62
8.3.10.0160.00417.68
8.3.00.0200.00817.81
8.2.290.0100.00718.96
8.2.280.0200.01016.97
8.2.270.0270.00916.97
8.2.260.0370.00616.97
8.2.250.0340.00716.97
8.2.240.0310.01116.97
8.2.230.0340.00716.97
8.2.220.0350.00616.97
8.2.210.0290.01216.97
8.2.200.0330.00716.97
8.2.190.0300.01116.97
8.2.180.0320.01116.97
8.2.170.0310.00517.70
8.2.160.0240.00417.94
8.2.150.0330.01217.77
8.2.140.0240.00417.79
8.2.130.0120.00717.73
8.2.120.0190.00117.64
8.2.110.0240.00517.70
8.2.100.0340.00817.76
8.2.90.0310.00917.95
8.2.80.0260.00217.63
8.2.70.0320.00817.88
8.2.60.0350.00817.73
8.2.50.0430.00817.66
8.2.40.0340.00717.80
8.2.30.0410.00917.58
8.2.20.0340.00517.80
8.2.10.0300.00917.77
8.2.00.0340.00617.65

preferences:
44.72 ms | 403 KiB | 5 Q