-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.php
More file actions
42 lines (38 loc) · 751 Bytes
/
array.php
File metadata and controls
42 lines (38 loc) · 751 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
<?php
function array_put_first($a, $prefix) {
$t = array();
foreach($a as $k => $v) {
if(strstr($v, $prefix)) {
$t[] = $v;
unset($a[$k]);
}
}
return array_merge($t, $a);
}
function asort2D(&$array, $field) {
$temp = array();
foreach($array as $key => $row) {
$temp[$key] = $row[$field];
}
asort($temp);
$temp2 = array();
foreach($temp as $key => $val) {
$temp2[$key] = $array[$key];
}
$array = $temp2;
return $temp2;
}
function arsort2D(&$array, $field) {
$temp = array();
foreach($array as $key => $row) {
$temp[$key] = $row[$field];
}
arsort($temp);
$temp2 = array();
foreach($temp as $key => $val) {
$temp2[$key] = $array[$key];
}
$array = $temp2;
return $temp2;
}
?>