Hi
To briefly summarise the thread - I am trying to find a way for calling
functions to store values in an n dimesional static aray within a cache
function, so that the calling functions can manage the cached values through
set/ get / is_locked / is_dirty etc helper functions.
The problem is how to pass the values in to the static array in the cache.
Variable variables don't seem to work with arrays, and I can't find a way to
get eval( ) to work either.
I am looking to create a static array inside the cache that will work like
this:
$data['key']['key2']['value'] = 'my old val' ;
$data['key']['key2']['is_locked'] = FALSE ;
$data['key']['key2']['is_dirty'] = TRUE ;
etc etc
I have found a rather crude mechanism that does work - but there must surely
be a better way. Here is a simple example of the mechanism, which uses
variable-length argument lists.
<?php
set( 'my new val', 'key', 'key2' ) ;
function set( $value )
{
$args = func_get_args( ) ;
$data['key']['key2']['value'] = 'my old val' ;
$data = array( $args[1] => array( $args[2] => array( 'value' =>
$value ) ) ) ;
// Check what we have in the array
$result = $data['key']['key2']['value'] ;
echo( "Result is: $result<br>" ) ;
?>
This is hardly pretty - I am sure I must be missing something better.
I would be more than grateful for any help with this
Thanks
Geoff Caplan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]