creating variable name by concatenating strings in php

前端 未结 4 2241
醉梦人生
醉梦人生 2020-12-05 04:16

I have a file named questions.php with an array as follows :

$question12 = array(\"Which is the tallest mountain\",\"Mt Everest\");

I am in

4条回答
  •  失恋的感觉
    2020-12-05 05:11

    You're looking for variable variables.

    $id = 12;
    $q = "question{$id}";
    $q = $$q[0];
    

    You should seriously consider looking into multidimensional arrays to stop having multiple arrays.

提交回复
热议问题