I'm starting with PHP and I have to do this exercise: As a data I can not use php functions
The exercise consists of entering a number through a form, this number indicates the length of the array and filling the array with random numbers. Once the array is created, subtract the first value of the array with the last one, the second with the penultimate and so on. Either even or odd the length of the array.
But I can not think of any way to do this last: (
What I have done:
echo 'Array: <br>';
$narray=$_POST['narray'];
for($i=0;$i<$narray;$i++){
$array[]=rand(0,20);
echo $array[$i].' | ';
}
echo '<br><br>';
for($i=0;$i<$narray;$i++){
echo $resta[]=$array[$i]-$array[$narray-1].'|';
}