Arrays

Zend PHP 7 Certification – Arrays – Objects as Arrays

This post covers the Objects as Arrays section of the Arrays chapter when studying for the Zend PHP 7 Certification.
The ArrayObject class allows objects to work as arrays.
Two constants are available in this class: STD_PROP_LIST and ARRAY_AS_PROPS.
STD_PROP_LIST ensures properties of the object have their normal functionality when accessed as list (var_dump, foreach, …

Zend PHP 7 Certification – Arrays – Array Functions

This post covers the Array Functions section of the Arrays chapter when studying for the Zend PHP 7 Certification.
A list of some of the common functions used when dealing with arrays can be seen below.
array_push()
This function pushes one or more elements onto the end of array.
<?php
$stack = array(“orange”, “banana”);
array_push($stack, …

Zend PHP 7 Certification – Arrays – Array Iteration

This post covers the Array Interation section of the Arrays chapter when studying for the Zend PHP 7 Certification.
There are several ways that we can iterate over arrays. For numeric arrays, a simple for loop might look like the below.
$numbers = array(0, 1, 2, 5, 10);

for ($i = 0; $i < ...

Zend PHP 7 Certification – Arrays – Multidimensional Arrays

This post covers the Multidimensional Arrays section of the Arrays chapter when studying for the Zend PHP 7 Certification.
A multidimensional array is an array containing two or more arrays. The array could look like the below example.
<?php
$array = array(
“foo” => “bar”,
42 …

Zend PHP 7 Certification – Arrays – Associative Arrays

This post covers the Associative Arrays section of the Arrays chapter when studying for the Zend PHP 7 Certification.
Associative arrays are arrays that have named keys. So rather than having numeric keys, we can have keys that are composed as strings.
$array = array(0 => ‘Jaguar’, 1 => ‘5.4’); // Numeric
$array2 = array(‘make’ …