Avatar of AUCKLANDIT
AUCKLANDIT
Flag 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.
PHP

Avatar of undefined
Last Comment
AUCKLANDIT

8/22/2022 - Mon
mickey159

How many $vx s do you have? Is this number fixed?
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
mickey159

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AUCKLANDIT

ASKER
thank you
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes