php - filter_var_array() order of execution and rules -


the following simple bit of code shows working of filter_var_array(),

 <?php  $data = array('age' => 21,      'rating' => 4,     'price' => 9.95,     'thousands' => '100,000.95',     'european' => '100.000,95'      );   $instructions = array('age' => filter_validate_int,      'rating' => array('filter' => filter_validate_int,         'options' => array('min_range' => 1,         'max_range' => 4)),      'price' => array('filter' => filter_sanitize_number_float,         'flags' => filter_flag_allow_fraction),      'thousands' => array('filter' => filter_sanitize_number_float,         'flags' => filter_flag_allow_fraction |         filter_flag_allow_thousand),      'european' => array('filter' => filter_validate_float,         'options' => array('decimal' => ','),         'flags' => filter_flag_allow_thousand) );  $filtered = filter_var_array($data, $instructions); var_dump($filtered); 

its pretty difficult grasp @ first glance whats order/way in function(filte_var_array()) executes .

given following line of code above snippet :

$filtered = filter_var_array($data, $instructions); 

does go check 1st key in $data , try , match conditions given in 1st key in $instructions ? , continues in order ? 1 more important question here function try , match 1st key element in $data 1st key validation rules in $instructions ? or go inside $instructions , search entire array matching key name ? in mean in $data suppose have following key order :

name => rating => stars => reviews => 

in instructions can have validation rule keys in different order :

rating => name => reviews => stars => 

??

what if have different names keys in $data , $instructions ? or if in $data in have 5 keys , in corresponding $instructions array have 4 ??

thanks .

tenali .


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -