Get array value using a string as the array name and indexes
<p>I am trying to send specific indexes from arrays by string to some php code to describe the data that I need to combine. The problem I am having is that SESSION does not seem to be available within the function Str_To_Array. What am I missing about scope here? Also if anybody can recommend a better way I would be every so grateful. PS i added the include in case including the function causes any abnormalities.</p>

<pre><code>function Str_To_Array($str) {

    $d = explode(':',$str) ;

    print_r($d[0]) ;

    $t = $d[0] ;

    $n = $$t ;

    if( !isset( $d[1] ) ) { return $n ; }

    $n = $n[$d[1]] ;

    return $n ;
}

include(DIR_ROOT . "php_function/Str_To_Array.php") ;

$test = '_SESSION' ;
$ARRANGE = Str_To_Array($test) ;&lt;----this says _SESSION is undefined
print_r($ARRANGE) ;
$ARRANGE = $$test ;&lt;----this works
print_r($ARRANGE) ;
</code></pre>
