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.
Be First to Comment