Built From Developers For Developers
» Kuikie.com » Snippets » PHP » Arrays » PHP. Remove Empty Elements from Array
    Date & Time
    Files & Directories
    User Interface

PHP. Remove Empty Elements from Array

Recently had an array serialized into a string separated with ; which had to be brought back to array. The empty elements were of course not needed. So here is how to remove the empty elements.

$rooms = array_filter(explode(';', $rooms), create_function('$a','return $a!="";'));
©2012 Sinevia Ltd Terms of Use         Privacy Policy Valid XHTML 1.0 Transitional