PHP variable in variable

Posted by FFish on Stack Overflow See other posts from Stack Overflow or by FFish
Published on 2010-03-24T11:07:31Z Indexed on 2010/03/24 11:13 UTC
Read the original article Hit count: 656

Filed under:
|
|
|

I have set an array in my config file that I use global in my functions.
This works fine, but now I want to pass the name of this array as a @param in my function.

// in config file:
$album_type_arr = array("appartamento", "villa");   

global $album_type_arr; // pull in from db_config
echo $album_type_arr[0];

function buildmenu($name) {
    $test = global $name . "_arr";
    echo $test[0];
}
buildmenu("album_type");

© Stack Overflow or respective owner

Related posts about php

Related posts about variable