-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayfun.php
More file actions
53 lines (40 loc) · 1.02 KB
/
arrayfun.php
File metadata and controls
53 lines (40 loc) · 1.02 KB
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
53
<?php
// sort , rsort,array_push, array_pop, array_shift, array_unshift, array_slice
$ids = [1, 2, 4, 5, 6];
$user = ['user1', 'user2', 'user3'];
array_push($ids, 4);
array_push($user, 'user4');
array_pop($ids);
array_pop($user);
array_shift($ids);
array_shift($user);
array_unshift($ids , 1);
array_unshift($user , 'user1');
// $ids2= array_slice($ids , 2, 3);
// var_dump($ids2);
array_splice($ids,1,1,'newid ');
array_splice($user,0,1,'newuser ');
$tags= 'php,program,pythn';
$tagsArray= explode(',', $tags);
// var_dump($tagsArray);
$tags= ['php', 'program', 'python'];
$tagsString= implode(' ', $tags);
var_dump($tagsString);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>array</title>
</head>
<body>
<div>
<h2>this is the array</h2>
<?php echo "<pre>"; ?>
<?php echo print_r($ids); ?>
<?php echo "<pre>"; ?>
<?php echo print_r($user); ?>
</div>
</body>
</html>