Trim all array elements (PHP)

Submitted by Gast (nicht überprüft) on So, 12/06/2020 - 18:17

Trim all array elements with PHP:

$trimmed_array = array_map('trim', $fruits);


To see the difference:

 

$fruits = [' apple ', 'orange ', ' mango', 'kiwi' ];

$trimmed_array = array_map('trim', $fruits);

echo " <pre>";
print_r( $trimmed_array );
print_r( $fruits );

 

Neuen Kommentar schreiben

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.