0

sorry for the title of my question i really don't know how to emphasize my problem but here is the sample array:

enter image description here

and here is my code

foreach ($_POST['noofguest'] as $keyg => $valueg) {

                echo $valueg. "<br />"; 

}

        foreach($_POST['room_no'] as $key => $value){

            foreach($value as $key2 => $value2){

                echo $value2 . " has " . $valueg . "<br />";
            }


        }

and the result of this is:

1

2

56 has 1

57 has 1

but this is not the result that i want, what i want is

1

2

56 has 1

57 has 2

is this possible??

1
  • If you have 'noofguest' => array(0=>'2',1=>'1') how are you getting 1 2 and not 2 1? Commented Sep 1, 2015 at 16:59

1 Answer 1

1

For the second loop, you want to receive the same index of the room_no but only inside the noofguest array. So that's exactly what you should do:

foreach($_POST['room_no'] as $key => $value)
  foreach($value as $key2 => $value2)
    echo $value2 . " has " . $_POST['noofguest'][$key2] . "<br />";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.