Tag Archives: php

Validation without a model in CakePHP

CakePHP offers an awesome set of validation methods, but they rely on defining what you want to validate within a model. Sometimes you just want to quickly validate a certain piece of data, or validate a set of data iteratively without touching the model. For that, you can import the Validation class and use its [...]

Unique items in a multidimensional array in PHP

array_unique() works fine for a single dimensional array, but falls down on multidimensional arrays because it relies on string comparisons. When it compares entries in a multidimensional array, it simply sees ‘Array’ === ‘Array’ and returns true.