Displaying elements of an array by loopingWe can loop through an array to display each element of the array. This code will display all the element of an array. This is very useful in many occasions where a list is to be displayed. We will see the application of this in check box value collection.
First we will create an array and then display each element of it.
Here is the code to create and display the value of the elements of an array.
Using sizeof function to display all elements using for loop
Displaying one elementBy using key or by index we can display one element at a time. Here is the code.
Using print_rWe can use print_r funciton which returns variables in human readable format. Here is the code.
The output of the above code is here.
Same way here is one more array
The output is here
There are other way like using foreach function to display the elements of an array
Number of User Comments : 1