Numeric Array in PHP

0
117

Numeric arrays can store numbers, strings and any object but their index will be represented by numbers. By default array index starts from zero. In other words, we can say arrays with a numeric index. Take a look at following example:

<html>
<body>
<?php

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

$names = array("alpha","beta","Gamma");



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

Run it on the localhost and you will get the result:

numeric-array-in-php

Leave a Reply