Jump to content

Three-Dimensional Array, help!


jamesxg1

Recommended Posts

Hiya peeps!

 

Here are my scripts;

 

test.php

<?php
include 'formValidation.php';
$new = new formValidation(
					array(
							array(
								'formname' => 'firstname',
								'value' => 'james',
								'options' => 'required, alllowercase, onlyletters',
								'name' => 'First Name'
								),
								array(
								'formname' => 'password',
								'value' => 'blahblah',
								'options' => 'required, oneuppercase, alphanumerical',
								'name' => 'Password'
								),
								array(
								'formname' => 'username',
								'value' => 'blahblah',
								'options' => 'required, oneuppercase, alphanumerical',
								'name' => 'Username'
								)
						)
					);
?>

 

formValidation.php

<?php
class formValidation {

	private $inputs;

	function __construct($inputs = array()) {
		foreach($inputs as $input_key => $input_value) {
			foreach($input_value as $key => $value) {
				echo $value . '<br />';
			}
		}
	}

	public function __prep($formname, $options, $value, $name) {

		echo $formname . ' ' . $options . ' ' . $value . ' ' . $name . '<br />';

	}
}
?>

 

This outputs;

 

firstname
james
required, alllowercase, onlyletters
First Name
password
blahblah
required, oneuppercase, alphanumerical
Password
username
blahblah
required, oneuppercase, alphanumerical
Username

 

But what i need to do is for every four values I need them to be sent to the __prep function. EG;

 

$this->__prep('firstname', 'required, alllowercase, onlyletters', 'james', 'First Name');

 

I have no idea how to do this tho, I have tried a for() loop, another foreach loop, array the first four values then foreaching them again. I'm stuck, someone please help!

 

Many thanks,

 

James.

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.