AUCKLANDIT
asked on
PHP foreach loop on $_Request
Hello,
Ok, say you send this to a php page test.php
test.php?p=abc&w=erw&v1=12 3,122,342$ v2=234,312 3,3123&v3= 34,3123,12 3
They get cleaned:
foreach (array_keys($_REQUEST) as $key) {
$$key = $mysqli->real_escape_strin g(($_REQUE ST[$key])) ;
}
Now I have these:
$p,$w,$v1,$v2,$v3,$v4
Forget about the $p & the $w.
I want to now loop through only the $vx (where x is the number)
foreach(of-the-ones-the-start-with -a-v) {
$v=$the-one-used-in-this-loop ;
$arr=explode(',', $v);
$first=$arr[0];
$second=$arr[1];
$third=$arr[2];
And now I do something with the $first,$second,$third
}
What needs to go here:
Thank you for viewing my question, any help appreciated.
Ok, say you send this to a php page test.php
test.php?p=abc&w=erw&v1=12
They get cleaned:
foreach (array_keys($_REQUEST) as $key) {
$$key = $mysqli->real_escape_strin
}
Now I have these:
$p,$w,$v1,$v2,$v3,$v4
Forget about the $p & the $w.
I want to now loop through only the $vx (where x is the number)
foreach(of-the-ones-the-start-with
$v=$the-one-used-in-this-loop
$arr=explode(',', $v);
$first=$arr[0];
$second=$arr[1];
$third=$arr[2];
And now I do something with the $first,$second,$third
}
What needs to go here:
of-the-ones-the-start-withAnd here:-a-v
$v=$the-one-used-in-this-loop;
Thank you for viewing my question, any help appreciated.
How many $vx s do you have? Is this number fixed?
ASKER
min of 1 max of 60 - will be different each time as a user form where they add rows if needed, up to a max of 60.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you