-
Notifications
You must be signed in to change notification settings - Fork 0
/
array.php
51 lines (42 loc) · 853 Bytes
/
array.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
<?php
$barang = array("panci","wajan", "piring");
$nama = ["han han", "hanasa"];
$nama[] = "Sofari"; // menambah data
$barang[1] = "sendok"; //mengganti nilai
unset($barang[0]);
var_dump($barang[2]); //mengakses data
var_dump($nama);
var_dump($barang);
var_dump(count($nama));
//array map
$name = [
"id" => "IDXuy56",
"name" => "Hanasa",
"address" => [
"city" => "Ciamis",
"country" => "Indonesia"
]
];
var_dump($name[id]); //"IDXuy56"
var_dump($name[address][country]); //"Indonesia" => nested array
//operator array
$first = [
"first" => "Han Han"
];
$last = [
"first" => "Sofari",
"last" => "Hanasa"
];
$full = $first + $last;
var_dump($full);
$nasi = [
"first" => "beras",
"last" => "air"
];
$leupeut = [
"last" => "air",
"first" => "beras"
];
var_dump($nasi == $leupeut); //true
var_dump($nasi === $leupeut); //false
?>