0

I use a few time ago php and this question sure it´s stupid for many experts in php, but i don´t know if it´s possible to do

I have this string :

$type_up="pics";

picture define other string, but I need define this string inside in other string, something as this for example :

$ext_$type_up_let

The result must be the same as I put : $ext_pics_let

Yes I know this it´s no right, but I put for understand, I need define this word "pics" inside other string, repeat, I don´t know if it´s possible, because I try search something about, and don´t find nothing and finally we think some people can help in this question

Arebhy Sridaran
  • 586
  • 12
  • 28
  • 7
    The answer is [`variable variables`](http://php.net/manual/en/language.variables.variable.php) and I highly suggest that you do not do this or else you will hate yourself when you have to go back and debug this code. I highly recommend using something sane and debuggable such as an associative array. – MonkeyZeus Apr 06 '18 at 17:20
  • 1
    ^^ agree, don't use variable variables unless the world is about to end and you just want to try it out due to a bucket list. – Andreas Apr 06 '18 at 17:31
  • However, since you asked so nicely. Here, have fun shooting yourself repeatedly in the foot `$type_up="pics"; ${'ext_'.$type_up.'_let'} = 'hi'; echo $ext_pics_let;` – MonkeyZeus Apr 06 '18 at 17:37
  • 1
    Possible duplicate of [Variable variables: when useful?](https://stackoverflow.com/questions/3582043/variable-variables-when-useful) – Patrick Q Apr 06 '18 at 17:39

0 Answers0