-1
<?php

$j7=6;
$b=7;

$test= '$j'.$b;

echo $test;

?>

How to make the result of echo $test is 6 instead of $j7?

David
  • 188,958
  • 33
  • 188
  • 262

1 Answers1

0

You're looking to do the following:

$test = "${'j'.$b}";
echo $test;      //Outputs 6

You're working with variable variables which essentially defines a variable based on another variable's contents.

Sunny Patel
  • 7,505
  • 2
  • 31
  • 42