Jump to content

Multidimensional Array Validation


rayman0487

Recommended Posts

Hi all, I'm working on creating a simple API for an application re-write, however I'm having a difficult time trying to accomplish request verification - in a simple way. Here is what I have so far....

$AvailableRequest = array(
array ('Request1'),
array ('Request2'),
array ('Request3', 'req' => array('parm1', 'parm2'), 'opt' => array('parm3')),
array ('Request4', 'opt' => array('parm1')),
array ('Request5', 'req' => array('parm1'), 'opt' => array('parm2'))
);

I use this array to store all the allowable request and they required (req) and optional (opt) parameters that can/must be submitted too. What I currently do is use a function that loops through the array using the submitted requested and makes sure that the request in valid. What I'd like to do next is make sure that all the keys in the req array were also submitted. For example.

api.php?request=Request5&parm1=Foo - This should work

api.php?request=Request5 - This should return an error response

 

Is there a simple way to accomplish this that I'm overlooking?

 

Thanks for all the help.

Link to comment
https://forums.phpfreaks.com/topic/272897-multidimensional-array-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.