a simple question

This is where you share YOUR scripts with others

Moderators: egami, macek, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Aug 23, 2012 1:15 pm

Your Code...

Code: Select all

for ($j=0; $j<4; $j++)
 {
 $given=array( //S O S 
"$j" => $_POST{"answer$j"}); 
echo "answer to".$j ."=> ". $given[$j] . "<br />";
 } //until hera it prints the given answers

 echo "<h1>SOSapanthsh sthn 0=> ". $given[0] . "<br /></h1>"; //but here ..prints a notice
 

Try this..

Code: Select all


$i = 4;
for ($j = 0; $j < $i; $j++) { 
$given[$j] = $_POST['answer'.$j];
echo "Answer to $j => $given[$j]<br>";
}

echo '<h1>SOSapanthsh sthn 0=> '.$given['0'].'</h1><br>';

echo '<pre>'; print_r($given); echo '</pre>';
 

Post Reply