I was trying to echo all the values of the $sel_arrays using the foreach loop within a function called country(). I was using the loop within the country() function and return the value $sel. But it does output only the single value Bangladesh. I want to get the all values of the $sel_arrays.Though I know that foreach loops iterates all the arrays values, But these codes does not give my expected result. Below my codes...
<?php
function country() {
$sel_arrays = array('Banglasesh','Pakistan','USA','India','Italy');
foreach( $sel_arrays as $sel ) {
return $sel;
}
}
echo country(); // output only Bangladesh. That i ain't wanting.
?>
I did not get it how it is happening. Please help to get all the values of the array.
return $sel;doecho $sel;