You are here: Home » PHP » PHP Numeric Arrays

PHP Numeric Arrays

29 Flares 29 Flares ×

In Numeric arrays, Arrays can store numbers, strings and any object but their index will be represented by numbers so it is called Numeric arrays. By default array index starts from zero. We can define PHP Numeric Arrays in two ways.

First Type to create Numeric Array in PHP

<html>
<body>
<?php
$numbers = array( 1, 2, 3, 4, 5);
foreach( $numbers as $value )
{
  echo "Value is $value <br />";
}
?>
</body>
</html>

Second Type to create Numeric Array

<html>
<body>
<?php
$numbers[0] = "one";
$numbers[1] = "two";
$numbers[2] = "three";
$numbers[3] = "four";
$numbers[4] = "five";

foreach( $numbers as $value )
{
  echo "Value is $value <br />";
}
?>
</body>
</html>

About Abhishek Sinha

I am Abhishek and I love to code on PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Scroll To Top
29 Flares Twitter 2 Facebook 2 Google+ 22 StumbleUpon 2 Pin It Share 0 LinkedIn 1 29 Flares ×