3v4l.org

run code in 300+ PHP versions simultaneously
<?php // inside a class method $quotes = $this->listQuotes(); // $quotes now contains a list of quotes: // var_dump($quotes) will output something like: // array (size=26) // 0 => // array (size=23) // 'order_number' => string '12345678' (length=8) // 'customer_number' => string '111111' (length=6) // 'status' => string 'active' (length=6) // 'expired_date' => string '2017-08-06' (length=10) // 'quote_total' => float 24.61 // 'lineitems' => // array (size=0) // empty // 1 => // array (size=23) // ... // PROBLEM: I need to add an element to each of the arrays called grand_total // The output should then look something like this: // // array (size=26) // 0 => // array (size=23) // 'order_number' => string '12345678' (length=8) // 'customer_number' => string '111111' (length=6) // 'status' => string 'active' (length=6) // 'expired_date' => string '2017-08-06' (length=10) // 'quote_total' => float 24.61 // 'lineitems' => // array (size=0) // empty // 'grand_total' => array(size=2) // 'tax_inclusive' => float 123.45 // 'tax_exclusive' => float 120.00 // ] // 1 => // array (size=23) // ... // Routine would be something like $quotes = $this->listQuotes(); array_walk($quotes, function($quote, $key) { $quote['grand_total'] = [ 'tax_inclusive' => 123.45, 'tax_exclusive' => 120.00 ] }); // Then var_dump($quotes) *should* give me the expected described as above... // // I've tried with array_walk, array_map, and even a foreach. No errors setting the value, but the original list that gets returned is unchanged.

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)
7.1.70.0190.00315.14
7.1.60.0280.01233.07
7.1.50.0320.01432.88
7.1.40.0270.01432.48
7.1.30.0260.01132.72
7.1.20.0230.01632.84
7.1.10.0170.00614.67
7.1.00.0150.00614.84
7.0.200.0170.00714.69
7.0.190.0160.00814.73
7.0.180.0120.01214.20
7.0.170.0140.00714.41
7.0.160.0930.01014.25
7.0.150.0140.00814.25
7.0.140.0070.01414.44
7.0.130.0220.00414.30
7.0.120.0190.00314.41
7.0.110.0220.00014.24
7.0.100.0130.01014.40
7.0.90.0190.00314.29
7.0.80.0190.00314.33
7.0.70.0120.00914.37
7.0.60.0180.00414.24
7.0.50.0150.00614.55
7.0.40.0160.00614.76
7.0.30.0050.00914.58
7.0.20.0170.00614.38
7.0.10.0190.00314.61
7.0.00.0140.00814.52

preferences:
137.34 ms | 1394 KiB | 7 Q