Is there any way to name a variable after another variable, I sort of made up this bit of code which I thought might work but it didn't

<php
$V_Name = 'variable';
$"$V_Name" = 'Hello';
print($variable);
?>

Bit of a long shot I know but I thought it might work,
Any other ideas, I wondered if there was a command like setvariable(); where you could set the variable name as a string but I couldnt find anything.
Regards,
Sam Rudge

You can use something called a variable variable(yeah, I know it's weird)

$variable="name";
$$variable = "Shawn";
echo $name; // prints Shawn

Thanks, That worked fine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.