Hello I am just starting my adventure with coding and I have a question regarding that.
$element are numbers: 1,5,10,20.
$liczba = tab[0] - then $liczba value is 1.
So if $element>$liczba, and liczba is 1, then tab[0] - which is 1 shouldn't fit that criteria.
So why when I echo $liczba I get all elements with 1?
And second question. Why when I echo $liczba beyond [] brackets I get only 20 result, not 1(which shouldn't be here),5,10,20?
Answer is probably obvious, but I can't figure it out.
<?php
$tab = array("1", "5", "10", "20");
$liczba = $tab[0];
foreach ($tab as $element)
{
if($element>$liczba)
$liczba = $element;
echo $liczba;
}
echo $liczba;
?>