Loading video...
Arrays
- An array is a composite data type meaning it can hold more than one piece of data simultaneously, unlike scalar data types.
- Arrays in PHP are treated as maps where values are associated, or mapped, to keys .
- Keys can only be either integers or strings. However, values can be any PHP data type, including other arrays.
- Array values can be repeated, but keys must be unique.
- Arrays with integers as keys are known as numerically-indexed, or simply, indexed arrays .
- Arrays with strings as keys are known as associative arrays .
- Arrays are typically declared using the array() construct.
- Associative arrays use the => operator to assign keys with values.
- Data in arrays is accessed using square bracket syntax .
- For indexed arrays, the integer key of the desired value is listed between the brackets. Indexed array keys always start with the index 0.
- For associative arrays, the string key of the desired value is listed in quotes between the brackets.
- print_r() is a function used to output the value of variables in a formatted fashion.
- Additional Resources:
Arrays
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.



































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview