diff --git a/api/search.php b/api/search.php
index f154f9a..6922611 100644
--- a/api/search.php
+++ b/api/search.php
@@ -1 +1 @@
-
Tkp
', $result);
$results = explode('', $resultsb[1]);
$rows = explode('', $results[0]);
//Adds each row to the result array
$i = 1;
$length = count($rows);
$results = array();
while($i < $length) {
$values = explode('', $rows[$i]);
//var_dump($values);
$name = explode(' | ', $values[1]);
$ean = explode('', $values[2]);
$store = explode('', $values[3]);
$category = explode('', $values[4]);
$starchb = explode('', $starchb[1]);
switch($starch[0]) {
case "#ffff66":
$starch[0] = 3; //No data
break;
case "#ff6666":
$starch[0] = 2; //Contains starch from wheat
break;
case "#66ff66":
$starch[0] = 1; //Contains no starch from wheat
break;
}
$lactoseb = explode(' | ', $lactoseb[1]);
switch($lactose[0]) {
case "#ffff66":
$lactose[0] = 3; //No data
break;
case "#ff6666":
$lactose[0] = 2; //Contains lactose
break;
case "#66ff66":
$lactose[0] = 1; //Contains no lactose
break;
}
$bsmb = explode('#000000">', $category[3]);
$bsm = explode('', $bsmb[1]);
$dlcb = explode('center">', $values[5]);
$dlc = explode('', $dlcb[1]);
$sourceb = explode('center">', $values[6]);
$source = explode('', $sourceb[1]);
$results[] = array(utf8_encode($name[0]), $ean[0], utf8_encode($store[0]), utf8_encode($category[0]), $starch[0], $lactose[0], $bsm[0], $dlc[0], $source[0]);
$i++;
}
function utf8_encode_all($dat) // -- It returns $dat encoded to UTF8
{
if (is_string($dat)) return utf8_encode($dat);
if (!is_array($dat)) return $dat;
$ret = array();
foreach($dat as $i=>$d) $ret[$i] = utf8_encode_all($d);
return $ret;
}
header("Content-type: application/x-json");
echo json_encode(array('api_version' => 0.1, 'results' => utf8_encode_all($results)));
?>
\ No newline at end of file
+ Tkp | ', $result);
$results = explode('', $resultsb[1]);
$rows = explode('
', $results[0]);
//Adds each row to the result array
$i = 1;
$length = count($rows);
$results = array();
while($i < $length) {
$values = explode('', $rows[$i]);
//var_dump($values);
$name = explode(' | ', $values[1]);
$ean = explode('', $values[2]);
$store = explode('', $values[3]);
$category = explode('', $values[4]);
$starchb = explode('', $starchb[1]);
switch($starch[0]) {
case "#ffff66":
$starch[0] = 3; //No data
break;
case "#ff6666":
$starch[0] = 2; //Contains starch from wheat
break;
case "#66ff66":
$starch[0] = 1; //Contains no starch from wheat
break;
}
$lactoseb = explode(' | ', $lactoseb[1]);
switch($lactose[0]) {
case "#ffff66":
$lactose[0] = 3; //No data
break;
case "#ff6666":
$lactose[0] = 2; //Contains lactose
break;
case "#66ff66":
$lactose[0] = 1; //Contains no lactose
break;
}
$bsmb = explode('#000000">', $category[3]);
$bsm = explode('', $bsmb[1]);
$dlcb = explode('center">', $values[5]);
$dlc = explode('', $dlcb[1]);
$sourceb = explode('center">', $values[6]);
$source = explode('', $sourceb[1]);
$results[] = array(utf8_encode($name[0]), $ean[0], utf8_encode($store[0]), utf8_encode($category[0]), $starch[0], $lactose[0], $bsm[0], $dlc[0], $source[0]);
$i++;
}
function utf8_encode_all($dat) // -- It returns $dat encoded to UTF8
{
if (is_string($dat)) return utf8_encode($dat);
if (!is_array($dat)) return $dat;
$ret = array();
foreach($dat as $i=>$d) $ret[$i] = utf8_encode_all($d);
return $ret;
}
header("Content-type: application/x-json");
echo json_encode(array('api_version' => 0.1, 'results' => utf8_encode_all($results)));
?>
\ No newline at end of file
|