ServerSideSkittles ServerSideSkittles - 3 months ago 29
PHP Question

Strip whitespace from associative array Keys

I have an associative that outputs whitespace in the key and value. I need to strip the whitespace from first letter and also the last letter and keep the space inbetween.

I have tried

$stripResults = array_filter(array_map('trim', $results));

This strips the value perfectly but not the key. How do I strip the key and value?

mnv mnv

Keys must be processed separately:

$a = array_map('trim', array_keys($stripResults));
$b = array_map('trim', $stripResults);
$stripResults = array_combine($a, $b);