why array_combine doesn't work?
Posted: Fri Sep 29, 2006 4:46 pm
Why array_combine doesn't combine two arrays in one 2dimensional?
Code: Select all
<?
if(isset($_POST['Submit']))
{
$id = array();
$text_box_value = array();
$niz = array();
foreach ($_POST as $fieldName => $value)
{
if (($fieldName == 'kolicina'))
{
$text_box_value[] = $value;
}
if (($fieldName == 'id'))
{
$id[] = $value;
}
}
$niz = array_combine($id, $text_box_value);
print_r($niz);
}
else
{
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">";
for($i=1; $i <= 10; $i++)
{
echo "<input type=\"hidden\" name=\"id\" value=\"$i\"/>
<input name=\"kolicina\" type=\"text\" value=\"$i\"/><br>";
}
echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />";
echo "</form>";
}
?>