I am having a weird problem. I am trying to do a check if the requested url is the same as the $item->link. I know they aren't the same, so I am trying to by exploding the two. I have the following code:

$request_URL = JUri::getInstance();
$request_URL = explode("/", $request_URL, 4);

$link = $item->link;
$link = explode("/", $link, 2);
$link = array_map('trim',array_filter(explode(',',$link[1])));

$request_URL = array_map('trim',array_filter(explode(',',$request_URL[3])));


The output:

array(1) { [0]=> string(29) "nieuws?view=archive&year=2017" } 
array(1) { [0]=> string(33) "nieuws?view=archive&year=2017" }

This is very weird, because it says that the first one has 29 characters and the second one 33, while they look exactly the same?

Does anyone know what this could be?


I assume the first one has just the character &, and the second one the encoded version &. Both will display to screen as an ampersand.

Updating the following line to

$request_URL = array_map('trim',array_filter(explode(',',htmlspecialchars($request_URL[3]))));

should illustrate this.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.