Link to home
Start Free TrialLog in
Avatar of AUCKLANDIT
AUCKLANDITFlag for New Zealand

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=123,122,342$v2=234,3123,3123&v3=34,3123,123

They get cleaned:
foreach (array_keys($_REQUEST) as $key) {
 $$key = $mysqli->real_escape_string(($_REQUEST[$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:
of-the-ones-the-start-with-a-v
And here:
$v=$the-one-used-in-this-loop;

Thank you for viewing my question, any help appreciated.
Avatar of mickey159
mickey159
Flag of United States of America image

How many $vx s do you have? Is this number fixed?
Avatar of AUCKLANDIT

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
Avatar of mickey159
mickey159
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you