Not a problem, just a bit of info.
Working through this book, been OK so far.
The script on page 77 either shows the top x movies, or a sorted top x movies, however if you choose less than 10 you will get a different result back becuase the sorting sorts ths whole array, but the displaying only shows the first x amount.
So change the code to this:
Code:
$subset = array_slice($favmovies, 0, $_POST["num"]);
if (isset($_REQUEST['sorted'])) {
sort($subset);
}
print_r($favmovies);
echo "<br>";
echo "<br>";
print_r($subset);
echo "<br>";
echo "<br>";
//list the movies
$numlist = 1;
while ($numlist <= $_POST["num"]) {
echo $numlist;
echo ". ";
echo pos($subset);
next($subset);
echo "<br>\n";
$numlist = $numlist + 1;
}
And for 3, you will get back :
1. Life of Brian
2. Stripes
3. Office Space
And for 3 sorted you wil get back:
1. Life of Brian
2. Office Space
3. Stripes
Which makes more sense to me.