Hello everyone,
I'm new to the forums, and semi new to PHP in general. Sorry if I post this in the wrong place 🙁
I'm trying to create a function that does a haystack search using $_SERVER['HTTP_HOST'], and using an array that contain keywords as the needle. If anyword within the array match a word inside the HTTP_HOST, I want that word to be displayed. However I am not having success with this.
Can someone please help me and let me know what I am doing wrong?
This is a snippet of my code
// $fetched pulls an array that contains 6 keywords array("site 1", "site 2", "site 3", etc)
public function fetchSite() {
$fetched = self::\pull($site);
$sites = false;
foreach ($fetched as $sites) {
if (strpos($_SERVER['HTTP_HOST'], $fetched) !== False) {
$sites = $fetched;
}
return $sites;
}
If you can give me some direction on how to solve this issue, I would greatly appreciate it!
Thanks in advanced