array_filter() is Your Friend
array_filter()
Simple, easy and useful. Have a form where a list has been created client-side? Fear they might leave part of that list blank? Turning that list into an array to save? If you’ve answered yes to those questions, then there are probably 2 of you that this will help. For those of you still saying yes, array_filter is pretty amazing.
With an $entry and a ‘callback’ you too can use array_filter() in no time.
// Your array $ray_lewis = ('Ravens', 'linebacker', 'may have stabbed someone', ''); // notice the blank piece there? Unacceptable! $defense_attorney = array_filter($ray_lewis); // do what you want with your array with no blanks // more deets on php.net
Short. Simple. Like my brain… and my attention…um… bridge? potato?
Subscribe
Login
0 Comments