$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.

  • one
    What is this stream of consciousness and how does it fit in with the direction of the resource? I remind you, HashCode is a question and answer forum. - xEdelweiss
  • The issue is that array_walk does not work as it should. - Oleg
  • It would work incorrectly if trim() accepted the reference. In your case, array_walk works correctly. - user6550 pm
  • @klopp, not right, well. Why then there is no result? - Oleg
  • And what result is expected? array_walk() in your example does exactly what it should: go through the array and, for each element, calls trim() . That the result trim() 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

1 answer 1

Everything is brilliantly simple!

 $property = array_map('trim', $property)