PHP - How to concatenation 2 php var for create a new php var?
I want to concatenation $test
with $i
for create a new php var.
like this but not work, how can i do ?
<?PHP
$i = "5";
$test_$i = "WELCOME";
echo $test_5;
?>
PHP - How to concatenation 2 php var for create a new php var?
I want to concatenation $test
with $i
for create a new php var.
like this but not work, how can i do ?
<?PHP
$i = "5";
$test_$i = "WELCOME";
echo $test_5;
?>
You have to use variable variables :
<?php
$i = "5";
${'test_' . $i} = "WELCOME";
echo $test_5; // echoes "WELCOME"
?>