Reputation: 1820
I am trying to track down why a link to remove a filter is not working on my site. And it appears to be because the links are being changed to have %5B0%5D and other varieties of letters and numbers with % added in
from what I gather this is the serialize function causing this?
Is there anything else that might cause that or is it definitely the serialize function?
Upvotes: 14
Views: 30706
Reputation: 925
as other comments said its [0]
encoded
and one way I used to get over it is to manually create the urls .
like : $queryParams = implode('&', array_map(fn($item) => "param={$item}", $Array));
I think in your code you are generating the links maybe using a function like http_build_query and in this function if you use it as intended in PHP docs like
$info = array(
'sudo' => 'placement',
'CPP' => 'course',
'FORK' => 'C',
);
http_build_query($info, '', '&');
all goes fin but if you used it like
$info = array('placement', 'course', 'C');
http_build_query(['param'=>$info]);
you will get %5B0%5D , %5B1%5D ...etc added , since this are [0] , [1] ... its the code trying to make line unique by using the arry id since the array passed dose not have a key value pairs .
Upvotes: 0
Reputation: 45500
It's called Percent-encoding and is used in encoding special characters in the url parameter values.
[0]
contains special characters so when encoded it gives %5B0%5D
where %5B
represents [
and %5D
represent ]
look for [0]
in your php .
Upvotes: 22
Reputation: 109597
Maybe you made an url like
$url = 'mypage.php?book=$list[0]';
instead of
$url = "mypage.php?book=$list[0]";
Maybe in an indirect manner (template?), otherwise you would have seen it.
Upvotes: 4
Reputation: 14427
Looks like an Array index to me. Those are url encoded values that are being added in there. It will take some work to figure out where. My suggestion is to step through the code to see what values are building those links.
Upvotes: 15