1
I’m having trouble asking this question:
Make a program that receives ten ages, weights and heights and calculates and shows:
The quantity of persons weighing more than 90 kg and less than 1,50 kg;
The percentage of persons aged between 10 and 30 among those over 1,90;
I created three input’s to receive the information (age, weight and height). In PHP they are inserted into an array through the explode, but I can’t relate the weight and height arrays to respond to the first point or relate the age and height arrays to answer the second point.
Code I have so far:
<form action="" method="post">
<label for="idade">Idade</label>
<input type="text" name="idade">
<label for="peso">Peso</label>
<input type="text" name="peso">
<label for="altura">Altura</label>
<input type="text" name="altura">
<input type="submit" name="enviar">
</form>
<?php
if(isset($_POST['enviar'])){
$cont = 0;
$soma = 0;
$media = 0;
$idades = explode(",", $_POST['idade']);
$pesos = explode(",", $_POST['peso']);
$alturas = explode(",", $_POST['altura']);
?>
Have you seen how the arrays look? Try to see that you will notice how the information is associated.
– Jorge B.
With
array_filter
you can remove elements from the array that do not satisfy a certain condition.– Woss