How to validate multidimensional array in Zend?

I am wondering what is the best way to validate multidimensional array using Zend_Validate with Zend_FilterInput.

Here is my current code:

$filters = array(
    'symbol'        => array('StripTags', 'StringTrim'),
    'mode'          => array('StripTags', 'StringTrim'),
);
$validators = array(
    'symbol'        => array('NotEmpty'),
    'mode'          => array('NotEmpty'),
);


$input = new Zend_Filter_Input($filters, $validators, $_POST);

I would like to append here an array, for example name[] array (posting an array with two/three names).

Here is a sample $_POST array:

array(
    'symbol' => 'SD34G',
    'mode'   => 'back',
    'name'   => array(
                       0 => 'Name A',
                       1 => 'Name B',
                       2 => 'Name C'
                )
)

Answers


Ok, I found that I should do it for an array with the same method as for string.

Zend_Filter_Input checks if value is array and does foreach with validating every its element.

So....

$filters = array(
    'symbol'        => array('StripTags', 'StringTrim'),
    'mode'          => array('StripTags', 'StringTrim'),
    'name'          => array('StripTags', 'StringTrim'),
);
$validators = array(
    'symbol'        => array('NotEmpty'),
    'mode'          => array('NotEmpty'),
    'name'          => array('NotEmpty'),
);

;-)


Need Your Help

Create Multidimensional HashMap in java

java arraylist hashmap xmlnode

I am kind of new to java, I have this code

Qt - Scrolling the Text under a widget

qt text scroll scrollview qwidget

Can anyone plz try to solve my problem. i have a frame, in that am scrolling a text. now i have added 2 widgets at both the ends of the frame. Using the stylesheet i had changed the color of the 2

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.