Passing array names into a function
| From: | Geoff Caplan | Date: | Wed, 05 Sep 2001 19:30:24 +0000 |
| Subject: | Passing array names into a function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-66086@lists.php.net to get a copy of this message | ||
Hi folks
I think I am being dumb but I just can't figure out a way to do this:
I have a static array inside a function, and I want caller to be able to
set/get values in the array.
Something like this:
<?php
data_store( "set", "my_array['key1']['key2']", "my new
value")
function data_store( $action, $variable, $value )
{
static my_array = array( ) ;
if( $action == "set" )
{
// set my new value
}
}
?>
I have been mucking about with eval( ) and with variable variables, but
can't get it to work.
Can some kind person point out what I am missing??
Thanks
Geoff Caplan