Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

artisticre's avatar

Remove %5B%5D from URL

I have this code and it is sorting correctly now. But the URL will add subcategory%5B%5D=1(id). How can I get rid of %5B%5D from the URL

<form action="{{ route('product.list',[$slug]) }}" name="subcatform" method="GET">
             @foreach($subcategories as $subcategory)
           
              <p><input type="checkbox" name="subcategory[]"
               value="{{$subcategory->id}}" class="mr-2"
               @if(isset($filterSubCategories))
                {!!in_array($subcategory->id,$filterSubCategories)?'checked ="checked" ':''!!}
               @endif

               >{{$subcategory->name}}</p>
           <!--end foreach-->
           @endforeach
          <input type="submit" value="Filter" class="btn btn-info">
         </form>
0 likes
1 reply
tykus's avatar
tykus
Best Answer
Level 104

%5B and %5D are percent-encoding of the [ and ] array brackets; generally I would prefer to either name the checkbox field differently; or build the query parameter as a comma-separated list, e.g. ?subcategory=1,2,3

1 like

Please or to participate in this conversation.