Page 134 - Open Soource Technologies 304.indd
P. 134
Web Technologies-I Deepak Mehta, Lovely Professional University
Notes Unit 6: Arrays
CONTENTS
Objectives
Introduction
6.1 Indexed versus Associative Arrays
6.1.1 Associative Arrays
6.1.2 Indexed Arrays
6.2 Identifying Elements of an Array
6.3 Storing Data in Arrays
6.3.1 Adding Values to the End of an Array
6.3.2 Assigning a Range of Values
6.3.3 Getting the Size of an Array
6.3.4 Padding an Array
6.4 Array Operations in PHP
6.4.1 Split an Array into Chunks
6.4.2 Combine an Array with Data Elements and the Other with its Keys
6.4.3 Merging Two or More Arrays
6.4.4 Searching for a Value in an Array
6.4.5 Sorting Arrays
6.5 Working with Array
6.6 Summary
6.7 Keywords
6.8 Review Questions
6.9 Further Reading
Objectives
After studying this unit, you will be able to:
• Differentiate between indexed and associative arrays
• Discuss how to identify elements of an array
• Understand how to storing data in arrays
• Discuss array operations in PHP
• Explain how to work with array
Introduction
An array is a data structure that contains a group of elements. Typically these elements are all
of the same data type, such as an integer or string. Arrays are commonly used in computer
programs to organize data so that a related set of values can be easily sorted or searched.
128 LOVELY PROFESSIONAL UNIVERSITY