trim db function
This commit is contained in:
@@ -24,14 +24,8 @@ function main(): void {
|
||||
$do_notify = in_array('--notify', $argv, true);
|
||||
|
||||
$pbdb = pull_db();
|
||||
|
||||
array_unshift($pbdb, [
|
||||
'name' => 'Night time',
|
||||
'extension' => '*271',
|
||||
]);
|
||||
|
||||
$blank = ['name' => ' ', 'extension' => ' '];
|
||||
array_splice($pbdb, 1, 0, array_fill(0, 5, $blank));
|
||||
|
||||
$pbdb = trim_db($pbdb);
|
||||
|
||||
$xml = pull_xml_file($file);
|
||||
|
||||
@@ -103,6 +97,22 @@ function pull_db(): array {
|
||||
return $pbdb;
|
||||
}
|
||||
|
||||
function trim_db($pbdb): array {
|
||||
array_unshift($pbdb, [
|
||||
'name' => 'Night time',
|
||||
'extension' => '*271',
|
||||
]);
|
||||
|
||||
$filtered = array_filter($pbdb, function ($item) {
|
||||
if (!is_array($item) || !isset($item['name'])) {
|
||||
return true;
|
||||
}
|
||||
$name = ltrim($item['name']);
|
||||
return stripos($name, 'inpatient') !== 0;
|
||||
});
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
function pull_xml_file($file): DOMDocument {
|
||||
$xmlString = file_get_contents($file);
|
||||
|
||||
Reference in New Issue
Block a user