Put var_dump($menu[$i]);
above the strpos if statement and check the array
PHP (strpos) Empty delimiter, but not empty
Question
I've got a $url
(wich I get with $_SERVER['REQUEST_URI']
) and a $menu
, that contains the Links from the web.
When I do: if(strpos($url, $menu) !== false)
to know if the URL and the Link contains at least xxx.php
(because can have xxx.php?aaaaaaa
), it throws me a warning of empty delimiter. I made an echo from both variables, and they are not empty at all.
My code goes something like this:
$menu = obtain_menu();
$url = $_SERVER['REQUEST_URI']; //getting the url
$url = end(explode("/", $url)); //obtain the page (xxx.php)
for($i = 0; $i <= 8; $i++) {
$active = "";
if(strpos($url, $menu[$i]['Link']) !== false)
$active = "active";
}
If I'm wrong I would appreciate you to teach me where and how.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow