array( string|integer key1 => mixed value1, string|integer key2 => mixed value2, string|integer key3 => mixed value3, )
In the following video, you will learn what an array data type is in PHP as well as the syntax, including how to access individual pieces of data within the array.
Visualization can help you to understand a concept. In this video, the array is demonstrated as post office boxes and an apartment building.
<?php namespace KnowTheCode; $main_st_homes = array( 1058 => array( 'floor1' => array( 100 => array( 'name' => 'Smith', ), 101 => array( 'name' => 'Thompson', ), ), 'floor2' => array( 200 => array( 'name' => '', ), 201 => array( 'name' => 'Nebs', ), 202 => array( 'name' => 'Jacobson', ), ), 'floor3' => array( 300 => array( 'name' => 'Reynolds', ), 301 => array( 'name' => '', ), 302 => array( 'name' => 'Tonya', ), ), 'floor4' => array( 400 => array( 'name' => 'Ballor', ), 402 => array( 'name' => 'Crest', ), ), 'floor5' => array( 500 => array( 'name' => 'Miller', ), ), ), ); ddd( $main_st_homes['floor3']['name'] );
You will grow in this profession when you incrementally and systematically stretch yourself....bit-by-bit.
Deep into the Array Data TypePro
In this video, you will go deeper into the instruction.
Understanding the KeysPro
Keys need to be either a string or an integer data type. What happens when you specify it as another data type, such as a floating point, boolean, etc.? The PHP Manual specifies how it type casts the key to the appropriate data type.
In this video, you will put the manual to the test by trying each of the data types. Let’s see what happens and then learn why.
The Internal PointerPro
In PHP, within the array data type there is a pointer. Its job is to keep track of its current element position. Functions use this pointer to traverse (move) through the elements of the array. In this video, you will learn about the pointer.