- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
- Parse error: syntax error, unexpected '}' in /in/daMKh on line 52
Process exited with code 255.
<?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.