Code: Select all
<?php
$nut=array('Bao','IM','Joel','Sacrifire','Serge','Skychin','Skylooker','Soulchild');
if(isset($_POST['reverse']) && $nut[0]=='Soulchild'):
rsort($nut);
elseif(isset($_POST['reverse']) && $nut[0]=='Bao'):
rsort($nut);
endif;
//show word
for($x=0;$x<8;$x++)
{
echo $nut[$x]." ";
if ($x%2!=0)
{
echo "</br>";
}
}
print_r($nut);
?>
<form action="array.php" method="post">
<input type="submit" name="reverse" value="Reverse!!">
</form>
My lecturer said the whole code should be in a one single php page.
The first click of reverse button successfully reversed the order of array but then the following does not..
Is there any problem within the php script?
Thanks for helping