-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
  • 208,112
  • 36
  • 198
  • 279

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,830
  • 2
  • 31
  • 46