Quantcast
Channel: how to create and concatenate dynamic variables in PHP? - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by Davide Berra for how to create and concatenate dynamic variables in PHP?

$
0
0

Yes you can. Just use brackets. Look at this example:

<?php$one = 1;$suffix_one = "_".$one;$suffix_two = "_2";$base_1 = "VALUE ONE";$base_2 = "VALUE TWO";echo ${"base".$suffix_one}." , ".${"base".$suffix_two};?>

Result:

VALUE ONE , VALUE TWO

Obviously, like other users said, you'd better use arrays. But i answered anyway for your information.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>