M12_GTO
05-03-2005, 11:50 PM
Hi,
I've got this code from a lecturer that demonstrates sessinos but I can't understand one line of it. I've looked on the Net but to no avail - this guy certainly does things differently!
<?php
session_start();
session_register();
?>
<HTML>
<HEAD></HEAD>
<BODY>
<?PHP
extract($_POST);
$ages[$name] = $age; //LINE I DON'T UNDERSTAND!!!
if(!isset($ages))
$ages = array();
foreach($ages as $name=>$age) {
print("<P>Name $name Age $age</P>");
}
?>
<FORM ACTION="dave.php" METHOD="get">
<P>Name:<INPUT TYPE="text" NAME="name"/></P>
<P>Age:<INPUT TYPE="text" NAME="age"/></P>
<INPUT TYPE="submit" VALUE="Add to array"/>
</FORM>
</BODY>
</HTML>
On the commented line I can't understand why it says $ages[$name] Where does this [$name] come from? Is this an array within the session?
I'll be very grateful if anyone can shed some light.
I've got this code from a lecturer that demonstrates sessinos but I can't understand one line of it. I've looked on the Net but to no avail - this guy certainly does things differently!
<?php
session_start();
session_register();
?>
<HTML>
<HEAD></HEAD>
<BODY>
<?PHP
extract($_POST);
$ages[$name] = $age; //LINE I DON'T UNDERSTAND!!!
if(!isset($ages))
$ages = array();
foreach($ages as $name=>$age) {
print("<P>Name $name Age $age</P>");
}
?>
<FORM ACTION="dave.php" METHOD="get">
<P>Name:<INPUT TYPE="text" NAME="name"/></P>
<P>Age:<INPUT TYPE="text" NAME="age"/></P>
<INPUT TYPE="submit" VALUE="Add to array"/>
</FORM>
</BODY>
</HTML>
On the commented line I can't understand why it says $ages[$name] Where does this [$name] come from? Is this an array within the session?
I'll be very grateful if anyone can shed some light.