Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ARRAYS
- Array is a complex type of variable which can store multiple amount of data in a single variable
- TYPE OF ARRAYS
- 1. Index Array
- An array with numeric key
- 2. Associative Array
- an array where each key has it's own specific value
- 3. Multidimensional Array
- An array containing one or more arrays within itself.
- */
- // INDEX ARRAY OR NUMERIC ARRAY
- $colors = array('Red', 'Green', 'Blue', 'Orange');
- echo $colors[0];
- echo '<br /><br /><br />';
- // $colors[0] = 'Red';
- // $colors[1] = 'Green';
- // $colors[2] = 'Blue';
- // $colors[3] = 'Orange';
- // Associative Array
- $ages = array('Peter' => 22, 'Marco' => 32, 'Josh' => 40);
- echo $ages['Peter'];
- // $ages['Peter'] = 22;
- // $ages['Marco'] = 32;
- echo '<br /><br /><br />';
- $contacts = array(
- array(
- 'name' => 'Peter Parker',
- 'email' => 'peterparker@gmail.com'
- ),
- array(
- 'name' => 'Clark Kent',
- 'email' => 'clarkkent@gmail.com'
- ),
- array(
- 'name' => 'Harry Potter',
- 'email' => 'harrypotter@gmail.com'
- )
- );
- echo $contacts[0]['name'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement