First of all, Happy New Year! πŸ™‚ I’ve been busy these past weeks. But I would like to spare some time today and share a little but useful tip on how to remove null or empty array values before finally saving it to the database. I recently stumble upon this issue and have found the set::filter core utility really helpful.

In certain situations that you encounter this.

[Product] => Array
            [0] => Array
                    [id] => 35
                    [url] => item35.php

            [1] => Array
                [id] =>     
                [url] => 


Basically you just add the utility before saving the data to remove the array values.

$this->data = Set::filter($this->data);

That’s about it. πŸ™‚