PHP Array in URL nicer

764

I'm currently thinking about following problem.

On one page I passGET data through form. URL after that looks like this:

example.com/data/array[]=1&array[]=2&array[]=3

And I would like to make it look like this:

example.com/data/array[]=1,2,3

It's a search filter page, that's why I don't usePOST, so eg. a user can send URL to friend.

I use Codeigniter framework. Any ideas guys?

218

Answer

Solution:

This is what happens if you have a HTML form where multiple items have the same NAME attribute. You can name the form elements differently, for example option1, option2, option3 and check for$_GET["option$i"] where $i = 1, 2 and 3.

People are also looking for solutions to the problem: php - How to echo a specific value in an array?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.