Backend code example on project for The School of Electrical and Computer Engineering of Applied Studies
✓ Published0🌍 Public
MMyoshu
Last edited Feb 20, 2018
Created on Feb 20, 2018
This example demonstrates a PHP search function that queries a JSON data file for matching terms and renders results through a Twig template. It reads `data.json` via `file_get_contents`, decodes it with `json_decode`, and loops through every key-value pair to check for case-insensitive matches using both `stripos` and a custom `Convertor::convertStringToLatin` method. The code measures query execution time with `microtime`, collects matching URLs in an array, and passes the results, search term, and duration to `search.twig` for display.
AI-generated description