How to Remove Empty Objects From Array In CakePHP

| By Webner

In CakePHP, to remove empty or ‘false’ values from an Array, use CakePHP’s static ‘filter’ method contained in ‘Hash’ class: $sampleArray = [ , false, true, 0, [‘one, ‘two, ‘three’] ] $sampleArray = Hash::filter($sampleArray); Here’s the array after filter method