Dec 2, 2010
I basically have two sets of data that I want to compare with a lot of different possibilities.
View 5 Replies
$data = array(
'object'=>'ball', // Should check VALID (Rule 2)
'color'=>'white', // VALID (Rule 2)
'heavy'=>'no', // VALID (Rule 1)
What I want to do is run $data through the $blueprint and make sure of the following:
If the $data key/value pair matches a $blueprint key/value pair, $data's k/v is valid If the $data key/value pair matches a $blueprint key and a value from the nested array, $data's k/v is valid If the $data array omits a key/value pair which exists in $blueprint, $data's k/v may still be valid if it is not located in the $required array If the $data array supplies a key/value pair which does not exist in $blueprint, $data's k/v is invalid If the $data key from a key/value pair matches a $blueprint value without a defined key, $data's k/v can still be valid. However, if the $blueprint has both a key and value defined, $data's k/v must meet the requirements of rule 1 to be valid. I'd like to impose a character limit on several of the $blueprint k/v where if a $data's k/v exceeds this character limit, $datas k/v is not valid
If a $data's k/v is invalid, I'd then like to somehow associate an error with that particular k/v describing why it is invalid (surpassed character limit, general error etc.) Perhaps the error would be defined in a third array?
I've looked into array_intersect_assoc but not sure if this is beyond the scope of that function. Also, there will be a good amount of values in the $blueprint, so I need something as versatile as possible.