I'm working with foreach loops for the first time and I don't understand exactly how to pull a value obtained inside the foreach loop out of the loop. Here I have a small example, my code is bigger but this will work:
<?php
$colors = array("red", "green", "blue", "yellow");
$pimpoyo= [];
foreach ($colors as $value) {
$pimpoyo= "$value <br>";
break;
}
echo $pimpoyo;
?>
Result: red
If I remove the break then I get the last value like this. I don't know how to get allof the values of $pimpoyo.
Any suggestions?