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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.