Skip to content

Commit a0d4aba

Browse files
committed
add array
1 parent bed4dfe commit a0d4aba

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

array.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
// array
3+
4+
$list = array(1, 2, 3, 4);
5+
$list = [1, 2, 3, 4];
6+
7+
print_r($list);
8+
9+
array_push($list, 50);
10+
$list[] = 600;
11+
12+
print_r($list);
13+
14+
// remove last element
15+
array_pop($list);
16+
print_r($list);
17+
18+
// remove first element
19+
array_shift($list);
20+
print_r($list);
21+
22+
$res = array_pop($list);
23+
var_dump($res);
24+
25+
$res = array_shift($list);
26+
var_dump($res);
27+
28+
print_r($list);

0 commit comments

Comments
 (0)