Arrays and their Operations
In this lesson. we will learn about printing arrays and finding length of an array.
We'll cover the following
As we discussed earlier, an array is like a list of values. The simplest form of an array is indexed by an integer, and ordered by the index, with the first element lying at index 0.
To debug your code while working with arrays, it is very important to view the keys and their associated values. Accessing the length of an array can also be useful on numerous occasions.
Outputting a Structured View of Arrays #
To print an array in a readable format we use the following:
print_r($arrayName)
This will print the keys and their associated values. Run the code below to see how print_r()
works.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy