santa
santa

Reputation: 12512

Validate vars in URL

If I know what vars I can have in my URL how do I validate my URL and ignore the ones that aren't on my list?

I suppose I will have all 'good' vars in an array

$good = array("name", "car", "year", "color");

Then I need to get the request URL, then break it apart looking for QUERY elements and loop those against my $good array, strip the ones that don't belong and process request. Seems like a good plan in theory. Or is there a better plan? If it's OK, how do I do all that?

$url = http://mydomain.com/?car=1&color=red&bad=asdasd

Upvotes: 1

Views: 45

Answers (1)

Piotr Olaszewski
Piotr Olaszewski

Reputation: 6204

Try use this: http_build_query.

Upvotes: 1

Related Questions