My Experiments with PHP
The following program defines and initializes an array to store data and the contents are displayed with a php program.
-------> Tested with Firefox browser.Code:<?php // Defining photos as an array $photos = array(); // Initialising the array with values $photos['0'] = "Cat"; $photos['1'] = "Rat"; $photos['2'] = "Tiger"; $photos['3'] = "Lion"; $photos['4'] = "Bear"; $photos['5'] = "Buffalo"; $photos['6'] = "Giraffe"; //count the elements in an array and stores the value in variable number $number = count($photos); echo 'The number of animals in the array photos is '.$number.'<br><br>'; // Displaying the elements of the array separated by a line break for ($i=0;$i<$number;$i++) { echo $photos[$i].'<br>'; }




Reply With Quote
Bookmarks