-4
$form = array(
    array(
        'form' => 'Change Schedule',
        'data' => array(
                    array(
                        'element'=>'input',
                        'name'=>'form-start',
                        'class'=>'form-control',
                        'type'=>'text',
                        'column'=>'col-md-12',
                        'label'=>'Schedule'
                    )
            ),
    ),
    array(
        'form' => 'Maintenance',
        'data' => array(
                    array(
                        'element'=>'input',
                        'name'=>'form-room-place',
                        'class'=>'form-control',
                        'type'=>'text',
                        'column'=>'col-md-12',
                        'label'=>'Room # / Place'
                    )
            ),
    ),
);

This is the array I made, I wanted to get the array with form = Maintenance only. Is this possible with php to get the array via string arrays I want to pass?

My attempt: $form(('form'=>'Change Dormitory'));

1
  • 1
    you usually access arrays via pointing to the appropriate index echo $form[1]['form'], like so, it seems you're having trouble with the basics, maybe you ought to try reading the manual php.net/manual/en/language.types.array.php Commented Jul 3, 2018 at 2:06

2 Answers 2

0

You've got 2 arrays inside the first array, so the internal arrays are $form[0] or $form[1].

You could then do $form[1]["form"] to get "Maintenance"

Sign up to request clarification or add additional context in comments.

Comments

0

if you want to get the array data inside form = "Maintenance",

you can filter by form value like this:

$newForm = array();
foreach ($form as $key => $value) {
    if ($value['form'] == 'Maintenance') {
        $arr[] = $value;
    }
}

var_dump($newForm);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.