-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayOperation.php
More file actions
44 lines (28 loc) · 887 Bytes
/
arrayOperation.php
File metadata and controls
44 lines (28 loc) · 887 Bytes
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
<?php
class arrayOperation{
//get depth of an array
static function array_depth(array $array) {
$max_indentation = 1;
$array_str = print_r($array, true);
$lines = explode("\n", $array_str);
foreach ($lines as $line) {
$indentation = (strlen($line) - strlen(ltrim($line))) / 4;
if ($indentation > $max_indentation) {
$max_indentation = $indentation;
}
}
return ceil(($max_indentation - 1) / 2) + 1;
}
//remove an element from an array
static function removeElementfromArray(array $array){
}
//add element to an array
static function addElementtoArray(array $array){
}
static function findElementandPositionFromArray(array $array){
}
static function updateElementinArray(){
}
static function mergeTwoArray(){
}
}