Posted by & filed under Programming.

Needed a quick way to go through and trim leading and trailing spaces off of a string array in PHP. I’ve used array_walk to do it before, but with the addition of anonymous functions it makes it a little quicker without having to do a separate function.

array_walk($ray, function($val) { return trim($val); });

Love those one line and done techniques.

Leave a Reply

Your email address will not be published. Required fields are marked *