John
Jane
Sam
Frank
Alex
Tammy
You have 20 kiwi
You have 12 oranges
You have 9 apples
You have 42 bananas
<?php
$testArr = array("John","Jane","Sam","Frank","Alex","Tammy");
foreach($testArr as $name) {
echo $name."<br>\n";
}
//to capture the actual index itself, consider this:
$fruit = array(
"kiwi" => 20,
"oranges" => 12,
"apples" => 9,
"bananas" => 42
);
foreach($fruit as $kind => $quant) {
echo "You have $quant $kind<br>\n";
}
?>
<?php //WILL DISPLAY CODE OF THIS FILE ON THE WEBPAGE//
######################################################################
echo "<br/><br/><hr><hr>";
echo "<h2 style='text-align:center'>END OF OUTPUT</h2>\n";
echo "<hr><hr>";
echo "<h2><br>Source Code of ".basename((string)__FILE__) . "</h2><hr>";
show_source(__FILE__);
#######################################################################
?>