I'm working on a project where I assign my URI list to a constant array.
$vars = explode("/", $_SERVER['REQUEST_URI']);
array_shift($vars);
if(end($vars) == "" && count($vars) > 0){ //remove last element when empty (occures when using / at the end of URL)
array_pop($vars);
}
define("URI_VARS", $vars);
unset($vars);
The big question is, how can I check if an item exists? If I use defined("URI_VARS")
, it of course works, but how can I check for instance does URI_VARS[1]
exist?
defined("URI_VARS[1]")
seems not to work. I found something online about defined("URI_VARS", "1")
or defined("URI_VARS" , 1)
but both are not working.
Thanks for the help!