Variable Variables and $_POST

I've got a multitude of strings on a site with a numerical suffix and am trying to use a loop (and later when working a function).
What I'm stuck on is the formatting to parse the variable text into $_POST so I can read the value from the previous page.
$VVBLE = "Number$LoopNumber";
$$VVBLE = $POST['$VVBLE'];

Open in new window

As highlighted above the $_POST['$VVBLE'] is what I'm stuck on, what formatting should I use for it to use that as the lookup value?
LVL 6
kiwistagAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Lukasz ChmielewskiConnect With a Mentor Commented:
Is this what you want ?

<?php
error_reporting(E_ALL);

$_POST['Number1'] = 100;
$_POST['Number2'] = 200;
$_POST['Number3'] = 300;

for($i=1;$i<=3;$i++)
{
    $LoopNumber = $i;
    $VVBLE = "Number".$LoopNumber;
    $$VVBLE = $_POST[$VVBLE];
}

var_dump($Number1);
var_dump($Number2);
var_dump($Number3);

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this should do it?
$$VVBLE = $POST[$VVBLE];
0
 
kiwistagAuthor Commented:
Thanks, the issue was actually (that I'd missed completely) that I'd put $POST and not $_POST. No idea why I kept overlooking it but your code was great for fault finding!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.