I'm trying to add a search bar to a UI Kit template. I have a JSON file that I want PHP to parse to only show a subset of the JSON file.
I have an example of what the JSON code needs to look like: Example
<?php
$json = json_encode(array(
"results" => array(
array(
"title" => "Google",
"url" => "http://google.com",
"text" => "A large search engine"),
array(
"title" => "Microsoft",
"url" => "http://microsoft.com",
"text" => "Devices and Services company"),
array(
"title" => "Apple",
"url" => "http://apple.com",
"text" => "iPad, iPhone, Mac, iOS"),
array(
"title" => "IBM",
"url" => "http://ibm.com",
"text" => "Innovators of hardware and software")
)
));
$_REQUEST['search'] = $json;
?>
I've tried several configurations without any luck.
Final Answer:
<?php
if ((isset($_REQUEST['search'])) && (!empty($_REQUEST['search'])))
{
$search_field= $_REQUEST['search'];
}
$json = json_encode(array(
"results" => array(
array(
"title" => "Google",
"url" => "http://google.com",
"text" => "A large search engine"),
array(
"title" => "Microsoft",
"url" => "http://microsoft.com",
"text" => "Devices and Services company"),
array(
"title" => "Apple",
"url" => "http://apple.com",
"text" => "iPad, iPhone, Mac, iOS"),
array(
"title" => "IBM",
"url" => "http://ibm.com",
"text" => "Innovators of hardware and software")
)
));
echo $json;
?>