fteinz
fteinz

Reputation: 1095

Multi dimensional array for a form

I want to check my input form with PHP.

And I want to fill an array with the false inputsbox name and the reason.

But I don't know how I get it multidimensional.

e.g.

$false = array();

if (!isset($_POST['name']) OR $_POST['name'] == "") {
    array_push($false, "name");
    //and here I want to to get a multi-dimension array and put the reason of the fales the the arraykey name
    //e.g. Sorry the name is missing!
}

if (strlen($_POST['name']) < 3) {
    array_push($false, "name");
    //and here I want to to get a multi-dimension array and put the reason of the fales the the arraykey name
    //e.g. Sorry the name is to short!
}

And now I want to get (if in the input form name stand nothing after submit) e.g.

false
(
    [0] => name
                (
                    [0] => Sorry the name is missing!
                    [1] => Sorry the name is to short!
                    [2] => etc etc
                )
    [1] => etc
                (
                    [0] => etc etc
                )
)

Could somebody please help me?

Upvotes: 0

Views: 136

Answers (1)

Stefan
Stefan

Reputation: 3041

$false = array();

if (!isset($_POST['name']) OR $_POST['name'] == "") {
    $false['name'][] = 'Sorry the name is missing!';
}

if (strlen($_POST['name']) < 3) {
    $false['name'][] = 'Sorry the name is to short!';
}

Upvotes: 1

Related Questions