0

?mr1=60,60,60,60,60&mr2=90,90,9&0,90,90&mr3=30,30,30,30,30
from the URL it should remove & ifit is there inbetween numbers(ie 90,90,9&0,90,90) and ignore this & if it is there like(60,60,60,60,60&mr2 ).

if after & mr2 or mr1 or mr3 then it should take the param value ,if it is inbetween should remove & only
how to use strpos() for this scenario.
can anyone help me to solve this.

Edited by malatamil: clear

3
Contributors
4
Replies
14
Views
1 Year
Discussion Span
Last Post by diafol
0

I assume these are GET arguments from a browser URL? If so, then each of mr1, mr2, and mr3 content strings would be avaliable in your PHP $_GET variables. So $_GET["mr1"] would return '60,60,60,60,60'. Anyway, show your code.

0

Why is your site throwing out misformed url parameters in the first place? Misformed urls should only really come from direct maniulation by the user. Trying to rectify misformed params is a bit pointless:

Validate the params - if they pass great, if not, let 'em know: "Stop being a dick with the url". :)

0

thanks, this is for manual testing before separating the param values i have to remove & in values.
i have to remove only
?mr1=60,60,60,60,60&mr2=90,90,9&0,90,90&mr3=30,30,30,30,30 before spliting the array

0

Check for the existence of each $_GET parameter and validate each one. I don't see why you have to mess around or be concerned with the position of '&'.

If you must have all 3 params:

if(isset($_GET['mr']) && isset($_GET['mr2']) && isset($_GET['mr3'])) ...

Once that test is passed, validate each, e.g. with regex. If you get a fail anywhere along the way, report it. Can't see the need to programmatically fix. If your program is spitting out bad urls, then you need to address it, not fix it. If users are entering bad params, tell 'em to stop it :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.