Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function searchTutorialByName($tutoname)
- {
- global $db;
- $query = $db->write_query("SELECT subject, tid, threadprefix.prefix FROM mybb_threads AS thread, mybb_threadprefixes AS threadprefix WHERE pid=thread.prefix AND subject LIKE '%". $tutoname . "%'");
- $tid = [];
- $prefix = [];
- $subject = [];
- while($result = $db->fetch_array($query)) {
- $subject[] = $result['subject'];
- $tid[] = $result['tid'];
- $prefix[] = $result['prefix'];
- }
- $data = array(
- "prefix" => $prefix,
- "subject" => $subject,
- "tid" => $tid
- );
- return json_encode($data, JSON_UNESCAPED_UNICODE);
- /*$data = array(
- "tutorial" => []
- );*/
- /*for ($i = 0; $i < count($prefix); $i++) {
- if (array_key_exists($prefix[$i], $data["tutorial"])) {
- $new_tid = $data["tutorial"][$prefix[$i]];
- $new_tid[$subject[$i]] = $tid[$i];
- $data["tutorial"] = array_replace($data["tutorial"],
- array_fill_keys(
- array_keys($data["tutorial"], $data["tutorial"][$prefix[$i]]),
- $new_tid
- )
- );
- } else {
- $data["tutorial"][$prefix[$i]] = array($subject[$i] => $tid[$i]);
- }
- }
- return json_encode($data, JSON_UNESCAPED_UNICODE);*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement