0

I want to receive multiple array in php like 3 array data . here is my html code

i want to receive three multiple array data using php

Example : id : 05 , star : 03 , review : test Example : id : 09 , star : 05 , review : test new
Array date : star[] , review[] , cast_id[] 
Data Recive :  $star , $review , $cast_id


<select class="form-control" name="star[]" required>
<option value="">Please Select</option>
<option value="1">1</option>
<option value="2">2 </option>
<option value="3">3 </option>
<option value="4">4 </option>
<option value="5">5</option>                            
</select>

<textarea class="form-control" rows="5" id="review[]" name="review[]</textarea>

<input name="cast_id[]" id="cast_id[]" type="hidden" value="<?php echo $cast_id; ?>">

Here I tried to receive the multiple array data and print but I only get the first array data so how can I get all data values

foreach($_POST['cast_id'] as $cast_id) {

foreach (array_combine($_POST['star'], $_POST['review']) as $star => $review) {

echo $cast_id."<br>";
echo $star."<br>";
echo $review."<br>";

//$reg_action = mysqli_query($con, "UPDATE job_apply_review SET star = '$star', review = '$review'  WHERE cast_id = '$cast_id'");



}

}

thank you

5
  • what you trying to achieve ? Commented Sep 18, 2017 at 12:16
  • Example : id : 05 , star : 03 , review : test Example : id : 09 , star : 05 , review : test new Commented Sep 18, 2017 at 12:17
  • Why are you doing an array_combine on your fields? And it's not clear at all what you're trying to do here Commented Sep 18, 2017 at 12:17
  • you can pass the key in your foreach and use that to reference the corresponding entries in the other arrays Commented Sep 18, 2017 at 12:21
  • i want to receive three multiple array data using php Example : id : 05 , star : 03 , review : test Example : id : 09 , star : 05 , review : test new Array date : star[] , review[] , cast_id[] Data Recive : $star , $review , $cast_id Commented Sep 18, 2017 at 12:21

1 Answer 1

1

You can use the array item's index to target the corresponding value in the other arrays:

foreach ($_POST['star'] as $index => $star) {

  $cast_id = $_POST['cast_id'][$index];
  $review = $_POST['review'][$index];

}
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.