-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlookup_script_based.php
More file actions
39 lines (30 loc) · 852 Bytes
/
lookup_script_based.php
File metadata and controls
39 lines (30 loc) · 852 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
<?php
include('JsonRfc.php');
// Allowed delimiters for concatening multiple fields to a label
$delimiters = array (',',' ','&');
$jsonParams = $_POST['jsonParams'];
$rfcResults = JsonRfc::execute($jsonParams,null,JsonRfc::$FORMAT_ARRAY);
$lookupParams = json_decode($jsonParams,true);
$lookupTable = $lookupParams['lookupTable'];
$label = $lookupParams['label'];
$value = $lookupParams['value'];
$results = array();
foreach($rfcResults['tables'][$lookupTable] as $row) {
if (is_array($label)) {
$labelString = "";
foreach($label as $l) {
if (in_array($l,$delimiters)) {
$labelString = $labelString . $l;
}
else {
$labelString = $labelString . $row[$l];
}
}
}
else {
$labelString = $row[$label];
}
array_push($results,array('value' => $row[$value], 'label' => $labelString));
}
echo json_encode($results);
?>