[UPHPU] easy asort() question
John M
johnm_ul at yahoo.com
Wed Jun 22 08:57:54 MDT 2005
> I suppose I am asking you to post the rest of the
> code. ;)
>
> -wtgee
Sorry, I figured my issue was within the code I had
posted.
Here is everything from the example I'm trying to
understand (with the exception of the $_REQUEST lines
I had to add to exam2.php)
exam.php
<?php
echo "<form method=post action='exam2.php'>";
$student = array("albert einstein", "ivan the
terrible", "napoleon", "simon bolivar", "isaac
newton");
while (list(,$name) = each($student))
{
echo "what grade did $name get in math?";
echo "<br><br>";
echo "<select name='math[]'><option>grade
a</option><option>grade b</option><option>grade
c</option><option>grade d</option><option>grade
f</option></select>";
echo "<br><br>";
echo "<input type=hidden name=student[]
value='$name'>";
}
echo "<input type=submit>";
echo "<input type=reset></form>";
?>
exam2.php
<?php
$student = $_REQUEST['student'];
$math = $_REQUEST['math'];
echo "in math the grades were in order:<br>";
while (list($index,$value) = each($math))
{
$gradestudent[] = $math[$index].$student[$index];
}
asort($gradestudent);
while (list($index,$value) = each($gradestudent))
{
echo "<br>$student[$index] - $math[$index]";
}
?>
My problem is the output from exam2.php is confusing
me. The output is sorted differently than I'm
understanding the official definition of asort().
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
More information about the UPHPU
mailing list