php array length for loop
Posted by Raj
php array length for loop
In this Article, I will explain How to get the size of array and then use the for loop to display all the data into the array.
sizeof :Get the actual length of array in PHP.
Syntax
sizeof(array)
count(array)
Example: Find array length for loop
<?php
$arr1 = array('A','B','C','D','E');
$size= sizeof($arr1); //Get php size of an array
echo "size of an array is:$size<br>";
for($i=0;$i<$size;$i++){
echo $arr1[$i]."<br>";
}
?>
Output:
size of an array is:5
A
B
C
D
E
In this Article, I will explain How to get the size of array and then use the for loop to display all the data into the array.
sizeof :Get the actual length of array in PHP.
Syntax
sizeof(array)
count(array)
Example: Find array length for loop
<?php
$arr1 = array('A','B','C','D','E');
$size= sizeof($arr1); //Get php size of an array
echo "size of an array is:$size<br>";
for($i=0;$i<$size;$i++){
echo $arr1[$i]."<br>";
}
?>
Output:
size of an array is:5
A
B
C
D
E
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
array php length,
array size in php,
length array php,
length of array in php,
php length of array,
php size,
php size of an array,
php size of array,
size array php,
size of array php
.You can leave a response, or trackback from your own site.