> -----Original Message-----
> From: Neil Freeman [mailto:[EMAIL PROTECTED]]
> Sent: 11 January 2002 12:03
>
> Who's awake today then? :) What I'm trying to do is create variable
> variable arrays and then fill these arrays with values. The problem I
> have though is that the values don't appear to be getting stored - as
> following the assignment I have outputted a 'sizeof' command which
> always outputs 0.
Once again, I can't help wondering why go all round the houses with $$ instead of
using arrays -- in this case, 2-dimensional ones (arrays of arrays!):
>
> Here's a snippet of the code. Any ideas guys???
>
> ...........
> //store children page_IDs into array for each parent
> $str_array = "menu_array_" . $current_parent_page_ID;
> $$str_array = array();
$str_array = array();
$str_array[$current_parent_page_ID] = array();
>
> for ($child_cnt = 0; $child_cnt < $number_children; $child_cnt++)
> {
> $db_help_structure->next_record();
>
> //get page_ID value
> $page_ID = $db_help_structure->return_single_result('page_ID');
>
> //$page_ID is now set
>
> echo "storing in $str_array position $child_cnt:" . $page_ID .
> "<br>";
> $$str_array[$child_cnt] = $page_ID;
$str_array[$current_parent_page_ID][$child_cnt] = $page_ID;
> echo "size:" . sizeof($$str_array) . "<br>";
> }
> ...........
Mind you, I've done no comparison of the relevant efficiencies of the $$ method and
the 2-dimensional array -- I just find the arrays easier to comprehend (and less prone
to syntactical problems!!).
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
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]