Solved

Variable Variables and $_POST

Posted on 2013-01-18
3
344 Views
Last Modified: 2013-01-18
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?
0
Comment
Question by:kiwistag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 400 total points
ID: 38792337
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38792369
this should do it?
$$VVBLE = $POST[$VVBLE];
0
 
LVL 6

Author Closing Comment

by:kiwistag
ID: 38792394
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question