-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeneralFunctions.php
More file actions
34 lines (29 loc) · 1.02 KB
/
generalFunctions.php
File metadata and controls
34 lines (29 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
<?php
function startsWithChar($needle, $haystack) {
return ($needle[0] === $haystack);
}
function endsWithChar($needle, $haystack) {
return ($needle[strlen($needle) - 1] === $haystack);
}
function consoleOutput($thing) {
$result = 'console.info( \'PHP Console output: \' );';
$result = $result . 'console.log(' . json_encode($thing) . ');';
}
function parseIniFile($file) {
if (!is_file($file))
return null;
$iniFileContent = file_get_contents($file);
return parseIniString($iniFileContent);
}
function parseIniString($iniFileContent) {
$iniArray = array();
$iniFileContentArray = explode("\n", $iniFileContent);
foreach ($iniFileContentArray as $iniFileContentArrayRow) {
$iniArrayKey = substr($iniFileContentArrayRow, 0, strpos($iniFileContentArrayRow, '='));
$iniArrayValue = substr($iniFileContentArrayRow, (strpos($iniFileContentArrayRow, '=') + 1));
if($iniArrayKey != ""){
$iniArray[$iniArrayKey] = $iniArrayValue;
}
}
return $iniArray;
}