$property = array( 'File size ', ' 25.1 KiB', ); array_walk($property, 'trim'); var_dump('<pre>' . var_export($property, true) . '</pre>');
Result:
string(92) " array ( 0 => 'File size ', 1 => ' 25.1 KiB', ) "
What do below - you know.
$property = array( 'File size ', ' 25.1 KiB', ); array_walk($property, 'trim'); var_dump('<pre>' . var_export($property, true) . '</pre>');
Result:
string(92) " array ( 0 => 'File size ', 1 => ' 25.1 KiB', ) "
What do below - you know.
Source: https://ru.stackoverflow.com/questions/213011/
All Articles
trim()
accepted the reference. In your case,array_walk
works correctly. - user6550 pmarray_walk()
in your example does exactly what it should: go through the array and, for each element, callstrim()
. That the resulttrim()
not assigned to these elements afterwards should not. In the documentation, it is clearly written:> If you need to specify the first parameter of funcname as a reference. That is even so: functiopn my_trim (& $ s) {$ s = trim ($ s); } array_walk ($ property, 'my_trim'); - user6550