+ 6

Change variable according to variable PHP

$type = username; $[$type] = ... I want to make the second variable the string of the first variable.

3rd Apr 2018, 2:58 PM
Arne Van Kerckvoorde
Arne Van Kerckvoorde - avatar
3 ответов
+ 4
Here. You reassign variable value using two $ marks and the variable name will change to the previous value. $a = "username"; $a = "toni"; echo $username;
3rd Apr 2018, 3:58 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
Replace [] with {}: ${$type} = ... Youre welcome :)
3rd Apr 2018, 4:12 PM
Jeff Block
Jeff Block - avatar
0
You have to write $type to get output of second variable
2nd Jan 2019, 4:03 AM
arpanjossan