ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming»
  • Programming Languages

PHP Code Example on Numeric Array

Updated on August 3, 2012

PHP code sample, php scripts sample, a php code example on Numeric array

Arrays is very important in every programming languages. Hence, the arrays in php play also an important rule to php programmer epeciallly when they deal series of data's. This hub contains a php code example on numeric array.

Note: Before you can test and run this php code example, you should know how to run a php file on your browser. The link below would give you the details on how to run a php file and the requirements on running a php code/scripts or file.

How to run a PHP file on your Browser Using XAAMP and Notepad++

Please save the following code as numericalarray.php

PHP Code Example on Numerical Array

	$student = array("J. Parker", "N. Smith", "M. Maclein", "A. Garfield", "R. Rutherford");
	$count = count($student);
	echo "<strong>The students in the Array are: </strong>". "<br/><br/>";
	for($i=0; $i<$count; $i++)
		echo $student[$i]. "<br /> ";

Sample Output on numericalarray.php

Do you want to test the code? For the sake of clarification, here is how to test the above code intended only for beginners:

1. Be sure that you installed XAAMP and Notepad++.

2. Open the Xaamp application and run the Apache and My SQL on the Xaamp Window.

3. Copy the code above in your notepad++ and save it to the drive where you installed the Xaamp, open the Xaamp folder on that drive and open the htdocs folder. On the htdocs folder where you will save the php file, better name it whileloop.php.

4. Now, go to your browser and type this: localhost/numericalarray.php. As soon as you hit enter, you will be directed similar to the sample output above.


    0 of 8192 characters used
    Post Comment

    No comments yet.