Jump to content

for each question


flemingmike

Recommended Posts

hello all,  i am having a for each problem.  im trying to get two post fields using the foreach function.

 

here is what i have in my form.php:

<?php
foreach($_POST['staff'] as $value) {
echo "$value -  <br />"; 
}
?>

 

the name of the the fields coming in are

name='staff[]'   and the second one is name='descr[]'

 

fields += 1;

Link to comment
https://forums.phpfreaks.com/topic/217039-for-each-question/
Share on other sites

if you're trying to access the same index from the $_POST['descr'] array, you'll actually need to grab the index from the $_POST['staff'] array in your foreach():

 

foreach ($_POST['staff'] AS $key => $val)
{
  echo 'Staff: '.$value.'<br />';
  echo 'Description: '.$_POST['descr'][$key].'<br />';
}

Link to comment
https://forums.phpfreaks.com/topic/217039-for-each-question/#findComment-1127260
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.