Back to PhocacartAttribute class

Method sanitizeAttributeArray

public static
sanitizeAttributeArray
(mixed $attribute)

Method sanitizeAttributeArray - Source code

public static function sanitizeAttributeArray($attribute)
{
    // Sanitanize data and do the same level for all attributes:
    // select attribute = 1
    // checkbox attribute = array(0 => 1, 1 => 1) attribute[]
    $aA = array();
    if (!empty($attribute)) {
        foreach ($attribute as $k => $v) {
            if (is_array($v) && !empty($v)) {
                foreach ($v as $k2 => $v2) {
                    if ((int) $v2 > 0) {
                        $aA[(int) $k][(int) $v2] = (int) $v2;
                    }
                }
            } else {
                if ((int) $v > 0) {
                    $aA[(int) $k][(int) $v] = $v;
                }
            }
        }
    }
    return $aA;
}