3v4l.org

run code in 300+ PHP versions simultaneously
<?php $st = '{"id":"PAY-000000000000000000000000","intent":"sale","state":"approved","cart":"11111111111111111", "payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"user@host.com","first_name":"NAME","middle_name":"XXX","last_name":"LNAME", "payer_id":"ZZZZZZZZZZZZZ","country_code":"MD"}},"transactions":[{"amount":{"total":"13.49","currency":"USD","details":[]}, "payee":{"merchant_id":"ZZZZZZZZZZZZZ","email":"PAYER@HOST.com"},"item_list":{"items":[{"name":"Package", "description":"Package","price":"8.49","currency":"USD","quantity":1},{"name":"donate","description":"Donate","price":"5.00", "currency":"USD","quantity":1}]},"related_resources":[{"sale":{"id":"0NRFFFFFFFFFFFFFF","state":"completed","amount":{"total":"13.49", "currency":"USD","details":{"subtotal":"13.49"}},"payment_mode":"INSTANT_TRANSFER","protection_eligibility":"INELIGIBLE","transaction_fee":{"value":"0.89", "currency":"USD"},"parent_payment":"PAY-000000000000000000000000","create_time":"2018-01-01T20:35:19Z","update_time":"2018-01-01T20:35:19Z", "links":[{"href":"https:\/\/api.paypal.com\/v1\/payments\/sale\/00000000000000000","rel":"self","method":"GET"}, {"href":"https:\/\/api.paypal.com\/v1\/payments\/sale\/00000000000000000\/refund","rel":"refund","method":"POST"}, {"href":"https:\/\/api.paypal.com\/v1\/payments\/payment\/PAY-000000000000000000000000","rel":"parent_payment","method":"GET"}]}}]}], "create_time":"2018-01-00T20:35:20Z","links":[{"href":"https:\/\/api.paypal.com\/v1\/payments\/payment\/PAY-000000000000000000000000", "rel":"self","method":"GET"}]}'; $reply = json_decode(trim(stripcslashes($st), '"'), true); echo "\nLets go!\n"; $fee = getKeyFromArray('transaction_fee', $reply); echo "\n++++++++++++++++++++++++++++\n"; print_r($fee); $fee = getFee($st); echo "\n++++++++++++++++++++++++++++\n"; print_r($fee); $fee = getTheFuckingKeyFromTheFuckingArrayWithoutFuckingTroubles('transaction_fee', $reply); echo PHP_EOL, "Why is PHP such a bad language?!", PHP_EOL; echo PHP_EOL, "++++++++++++++++++++++++++++", PHP_EOL; echo PHP_EOL, print_r($fee, 1); function getFee($s) { // we need to locate something like this // "transaction_fee":{"value":"0.89","currency":"USD"} $p = strpos($s, 'transaction_fee'); $max = strlen($s); echo "\nGot p = $p\n"; if ($p > 0) { // scan for '{' to '}' $p1 = $p; while ($s[$p1] != '{' && $p1 < $max) { $p1++; } echo "\nGot p1 = $p1\n"; $p2 = $p1; while ($s[$p2] != '}' && $p2 < $max) { $p2++; } echo "\nGot p2 = $p2\n"; $r = substr($s, $p1, $p2 - $p1).'}'; return @json_decode($r, true); //return $r; } else { echo "WTF2????"; return null; } } function getKeyFromArray($dataItemName, $array) { foreach ($array as $key => $value) { echo "\nChecking ".(string)$key."\n"; if ((string)$key == $dataItemName) { echo "\nGot needle!\n"; return $value; } if (is_array($value)) { echo "\n ".(string)$key." is an array, going deeper.\n"; echo "\n============================\n"; print_r($value); echo "\n============================\n"; return getKeyFromArray($dataItemName, $value); } } echo "\nWTF???\n"; return null; } /** * @param string $theFuckingKey * @param array $theFuckingArray * * @return mixed|null */ function getTheFuckingKeyFromTheFuckingArrayWithoutFuckingTroubles/* please */($theFuckingKey, array $theFuckingArray) { foreach (new \RecursiveIteratorIterator(new \RecursiveArrayIterator($theFuckingArray), RecursiveIteratorIterator::SELF_FIRST) as $key => $value) { if ($key === $theFuckingKey) { return $value; } } return null; }

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.30.0100.00820.89
8.5.20.0080.01019.52
8.5.10.0100.00918.25
8.5.00.0160.01020.31
8.4.180.0050.00719.72
8.4.170.0100.01123.82
8.4.160.0140.00823.00
8.4.150.0080.00516.86
8.4.140.0130.00917.62
8.4.130.0060.00317.64
8.4.120.0090.00420.59
8.4.110.0110.00922.35
8.4.100.0040.00717.81
8.4.90.0130.00817.68
8.4.80.0100.00919.58
8.4.70.0140.00817.79
8.4.60.0150.00618.69
8.4.50.0130.00818.86
8.4.40.0100.01017.59
8.4.30.0070.00719.50
8.4.20.0120.00920.69
8.4.10.0060.00317.76
8.3.300.0110.01020.72
8.3.290.0160.01020.91
8.3.280.0150.01118.68
8.3.270.0160.00416.74
8.3.260.0090.00816.50
8.3.250.0110.00618.87
8.3.240.0090.01016.54
8.3.230.0090.00816.75
8.3.220.0060.00217.13
8.3.210.0130.00816.61
8.3.200.0060.00216.54
8.3.190.0120.01016.51
8.3.180.0050.01216.55
8.3.170.0090.01018.79
8.3.160.0120.00616.75
8.3.150.0110.00718.93
8.3.140.0140.00418.45
8.3.130.0030.00618.31
8.3.120.0030.00619.22
8.3.110.0130.00320.94
8.3.100.0000.01124.06
8.3.90.0040.00726.77
8.3.80.0060.00317.97
8.3.70.0070.01416.63
8.3.60.0060.00918.18
8.3.50.0090.00718.23
8.3.40.0110.00718.80
8.3.30.0120.00318.79
8.3.20.0080.00020.39
8.3.10.0060.00323.61
8.3.00.0040.00419.85
8.2.300.0160.00720.53
8.2.290.0140.00522.62
8.2.280.0130.00518.46
8.2.270.0100.01017.34
8.2.260.0040.00416.95
8.2.250.0150.00016.43
8.2.240.0070.00417.24
8.2.230.0200.00022.58
8.2.220.0000.00937.54
8.2.210.0040.01426.77
8.2.200.0140.00418.16
8.2.190.0120.00318.16
8.2.180.0180.00016.42
8.2.170.0140.00022.96
8.2.160.0070.00720.35
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00419.29
8.2.120.0040.00426.35
8.2.110.0080.00422.15
8.2.100.0120.00017.97
8.2.90.0080.00017.84
8.2.80.0040.00419.15
8.2.70.0040.00417.80
8.2.60.0000.00818.05
8.2.50.0000.00818.21
8.2.40.0000.00820.59
8.2.30.0050.00219.48
8.2.20.0040.00418.18
8.2.10.0030.00518.17
8.2.00.0030.00518.43
8.1.340.0140.00617.73
8.1.330.0120.00718.41
8.1.320.0130.00617.78
8.1.310.0060.00316.10
8.1.300.0040.00416.08
8.1.290.0040.00830.84
8.1.280.0110.00425.92
8.1.270.0030.00523.73
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0120.00022.32
8.1.230.0120.00322.70
8.1.220.0040.00417.77
8.1.210.0030.00718.77
8.1.200.0030.00517.61
8.1.190.0040.00417.65
8.1.180.0030.00618.10
8.1.170.0080.00018.61
8.1.160.0060.00318.94
8.1.150.0040.00420.27
8.1.140.0000.00817.65
8.1.130.0070.00017.47
8.1.120.0040.00417.54
8.1.110.0080.00017.59
8.1.100.0060.00317.59
8.1.90.0000.00717.50
8.1.80.0060.00317.52
8.1.70.0040.00417.48
8.1.60.0040.00417.67
8.1.50.0000.00817.62
8.1.40.0030.00617.61
8.1.30.0050.00317.60
8.1.20.0080.00017.67
8.1.10.0040.00417.58
8.1.00.0000.00817.54
8.0.300.0040.00420.39
8.0.290.0070.00016.88
8.0.280.0070.00018.52
8.0.270.0000.00717.31
8.0.260.0040.00416.89
8.0.250.0090.00017.01
8.0.240.0040.00416.95
8.0.230.0070.00017.01
8.0.220.0000.00716.94
8.0.210.0070.00016.90
8.0.200.0040.00417.02
8.0.190.0000.00717.01
8.0.180.0030.00916.87
8.0.170.0040.00416.95
8.0.160.0000.00917.01
8.0.150.0040.00416.89
8.0.140.0080.00016.84
8.0.130.0060.00013.43
8.0.120.0000.00816.92
8.0.110.0080.00016.86
8.0.100.0050.00217.00
8.0.90.0040.00416.73
8.0.80.0160.00016.95
8.0.70.0040.00416.80
8.0.60.0040.00416.85
8.0.50.0030.00516.84
8.0.30.0070.01117.27
8.0.20.0120.00717.41
8.0.10.0070.00017.11
8.0.00.0060.01316.88
7.4.330.0030.00315.55
7.4.320.0040.00416.43
7.4.300.0030.00316.64
7.4.290.0040.00416.66
7.4.280.0090.00316.66
7.4.270.0050.00516.57
7.4.260.0030.00316.49
7.4.250.0050.00216.54
7.4.240.0080.00016.62
7.4.230.0000.00716.54
7.4.220.0070.00016.46
7.4.210.0040.01116.55
7.4.200.0000.00716.40
7.4.160.0100.00816.61
7.4.150.0110.00717.40
7.4.140.0120.00617.86
7.4.130.0060.01216.66
7.4.120.0120.00816.58
7.4.110.0090.00916.51
7.4.100.0030.01716.51
7.4.90.0150.00416.54
7.4.80.0130.00719.39
7.4.70.0100.00716.61
7.4.60.0040.01416.58
7.4.50.0040.01116.47
7.4.40.0060.01016.45
7.4.00.0040.01214.88
7.3.330.0000.00513.46
7.3.320.0040.00413.39
7.3.310.0070.00016.44
7.3.300.0030.00316.41
7.3.290.0110.00616.45
7.3.280.0110.00516.42
7.3.270.0080.01117.40
7.3.260.0140.00916.47
7.3.250.0070.01116.54
7.3.240.0120.00616.54
7.3.230.0080.00816.34
7.3.210.0120.00616.37
7.3.200.0060.01016.68
7.3.190.0060.01116.68
7.3.180.0090.00916.32
7.3.170.0070.01416.51
7.3.160.0040.01816.67
7.3.10.0170.00716.19
7.3.00.0070.01116.40
7.2.330.0060.01216.48
7.2.320.0140.00316.88
7.2.310.0190.00316.96
7.2.300.0080.00916.52
7.2.290.0100.01016.62
7.2.130.0120.01516.41
7.2.120.0190.01116.61
7.2.110.0220.00316.28
7.2.100.0150.01116.49
7.2.90.0090.00916.25
7.2.80.0100.00916.84
7.2.70.0030.01316.39
7.2.60.0150.00716.81
7.2.50.0040.01616.61
7.2.40.0140.01416.58
7.2.30.0120.00916.60
7.2.20.0280.01017.68
7.2.10.0250.01317.47
7.2.00.0380.01017.45
7.1.250.0070.02115.37
7.1.200.0120.00615.68
7.1.140.0240.00816.64
7.1.130.0260.01116.66
7.1.120.0290.01216.54
7.1.110.0290.01016.01
7.1.100.0390.00816.05
7.1.90.0360.00716.04
7.1.80.0330.01116.24
7.1.70.0270.00715.39
7.1.60.0500.02233.23
7.1.50.0440.01333.00
7.1.40.0490.01332.53
7.1.30.0510.01432.75
7.1.20.0500.01432.95
7.1.10.0340.01114.99
7.1.00.0300.01114.81

preferences:
109.65 ms | 1719 KiB | 5 Q