-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
49 lines (43 loc) · 873 Bytes
/
functions.php
File metadata and controls
49 lines (43 loc) · 873 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
45
46
47
48
49
<?php
/*
* Application-specific utility functions.
*/
// Parses comma-separated values into an array of strings.
// Pass a callback function to modify the array.
function csv_to_array($csv, $callback = null)
{
if (is_null($csv) || $csv === '') {
$ret = array();
}
elseif (is_array($csv)) {
$ret = $csv;
}
elseif (is_string($csv)) {
$ret = explode(',', $csv);
if (!is_null($callback)) {
foreach ($ret as &$value) {
$value = $callback($value);
}
}
}
return $ret;
}
// Convert an array to a comma-separated value string.
function array_to_csv($arr)
{
return implode(',', $arr);
}
// Format a DateTime object to a MySQL-compatible datetime string.
function datetime_to_string($datetime)
{
return $datetime->format('Y-m-d H:i:s');
}
/*
* Testing functions
*/
function pre_var_dump($obj)
{
echo '<pre>';
var_dump($obj);
echo '</pre>';
}