Arrays and functions
Lists, associative arrays and your own functions.
About 4 hours of study
Learning objectives
- Store many values in arrays
- Look up values by key
- Write reusable functions
Lessons
- 1
Arrays
Lists of values: indexes, adding and removing items, sorting, searching and tables made of arrays.
- 2
Associative arrays
Arrays with names as keys: reading and changing pairs, safe reads, sorting by key or value, counting and records.
- 3
Functions
Writing your own functions: parameters, return values, types, defaults, named arguments, references and recursion.
Module practice
- PHP: Sort a listEasy
- PHP: Remove repeatsMedium
- PHP: Rotate a listHard
- PHP: Count the lettersEasy
- PHP: A phone bookMedium
- PHP: Rank the playersHard
- PHP: A power functionEasy
- PHP: List the primesMedium
- PHP: Fibonacci with memoryHard
Module quiz
‹ Input, decisions and loopsClosures, built-in functions and objects ›