-
Notifications
You must be signed in to change notification settings - Fork 2
/
arrays.php
52 lines (44 loc) · 1.01 KB
/
arrays.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
#Array - Variable that holds multiple values
/*
- Indexed
- Associative
- Multi-dimensional
*/
//!Indexed
$people = array('Kevin', 'Jeremy', 'Sara');
$ids = array(23, 55, 12);
$ages=[1,5,2,4,3,9];
$cars = ['Honda', 'Toyota', 'Ford'];
$cars[3] = 'Chevy';
$cars[] = 'BMW';
// echo $ages[5];
// echo count($cars);
// print_r($cars); //without data type
// var_dump($cars); //with data type
//echo $people[3];
//echo $ids[2];
//echo $cars[4];
//!Associative arrays
$people = array('Brad' => 35, 'Jose' => 32, 'William' => 37);
$ids = [22 => 'Brad', 44 => 'Jose', 63 => 'William'];
// echo $people['Brad'];
// echo $ids[22];
$people['Jill'] = 42;
// echo $people['Jill'];
//print_r($people);
// var_dump($people);
//!Multi-Dimensional
$cars = array(
array('Honda', 20, 10),
array('Toyota', 30, 20),
array('Ford', 23, 12)
);
$users=[
["Akshit",20],
["Mahesh",35]
];
echo $users[0][0];
// var_dump($users)
// echo $cars[1][2];
?>