I am trying to trim all values of arrays, which are located in an array, but so far I am not able to use array_walk_recursive properly - the values aren't trimmed after the array_walk_recursive is run. (in this case $test is returning true) This is my code so far:
$array = [
[
'component' => 'string ',
'productID' => 1,
'no_cas' => '85085-34-3',
'no_einecs' => '285-364-0',
'isComponent' => true
],
[
'component' => 'string2 ',
'productID' => 2,
'no_cas' => '92128-34-2',
'no_einecs' => '295-728-0',
'isComponent' => true
],
];
function trimAll($item, $key){
return trim($item);
}
$test = array_walk_recursive($array, 'trimAll');
var_dump('<pre>', $test , '</pre>');die;
function trimAll(&$item) {$item = trim($item);}array_walk_recursivereturnsbool. Print$arrayinstead.