click below button to copy the code. php tutorial - team
php 7 Sample Code : sample php program
<!DOCTYPE html><html><head><title>Foreach-Loop</title></head><body><?php$sample = array('zero','one','two');
echo "First index value - $sample[0]";
echo "<br>";
echo "Second index value - $sample[1]";
echo "<br>";
echo "Third index value - $sample[2]";?></body></html>
click below button to copy the code. php tutorial - team
php program Code Explanation :
In this statement we define the indexed array for the variable “$sample” by using array function and the value are separated by using commas (,).
In this echo statement we print the content “first index value and “$sample [0]” variable value. In the same way remaining two echo statements will be printed.
php coding Sample Output :
For the array “sample” the index value “0” prints the echo statement "First index value -Zero”.
for the array “sample” the index value “1” prints the echo statement "Second index value -One”.
For the array “sample” the index value “2” prints the echo statement "Third index value -two”.