1

i have some thing like this in my html multi checkbox

<label for="Status"><h2>Status:</h2></label>
<input type="checkbox" name="status[]" value="new">New<br>
<input type="checkbox" name="status[]" value="assigned">Assigned<br>
<input type="checkbox" name="status[]" value="resolved">Resolved<br>
<input type="checkbox" name="status[]" value="verified">Verified<br>
<input type="checkbox" name="status[]" value="closed">Closed<br>

myphp

$status = $_POST["status"];

$url = "http://some-example.com/project="abc" and state in [".$status."]/";
header("Location:$url");

i want the url to be like:

$url = "http://some-example.com/project="abc" and state in ["new","assigned","resolved","verified","closed"]/

is it possible to do this? if so please help.

1

1 Answer 1

2

Use http_build_query :

$url = "http://some-example.com/" . http_build_query([
    "project" => "abc",
    "state" => ["new","assigned","resolved","verified","closed"]
]);

Output :

http://some-example.com/project=abc&state%5B0%5D=new&state%5B1%5D=assigned&state%5B2%5D=resolved&state%5B3%5D=verified&state%5B4%5D=closed
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.