Re: [PHP] variable array name



On Nov 29, 2007 7:47 AM, Mark Head <mark.head@xxxxxxxxxxxx> wrote:
I seem to be having a problem in assigning a value to an array where the
array is called dynamically.

e.g. the physical name for the array is "my_array", so:
my_array[1] = "test";
works fine.

$array_name = "my_array";
$array_name[1] = "test";
does not work.

I have tried $$array_name[1] = "test"; but to no avail.

Any Ideas?

Cheers,

Mark

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



<?
$array_name = "mine";
$$array_name = array("This","is","how","it","should","be","done.");

print_r($mine);

$$array_name = array($$array_name,"Then","do","this","to","nest","inside","the","array.");

print_r($$array_name);
?>


--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.
.



Relevant Pages

  • Re: [PHP] foreach question
    ... Even though the user should be separating the lines with a line break, this turns into one long string with line breaks in it, not separate array elements. ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] Echoing input w/o sanatizing - what is the danger
    ... filtering input and escaping output are topics on ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] Question about user management...
    ... You are defining user role ids as MD5 hashes of UUIDs created from random numbers that change on every request? ... Maybe Tedd or Dan need to slap some sense into me, ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] Echoing input w/o sanatizing - what is the danger
    ... and making database calls with it, you will want to look for MySQL ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ... Use the coupon code phpgeneralaug07 ...
    (php.general)
  • Re: [PHP] foreach question
    ... A textarea does not produce an array. ... should be separating the lines with a line break, ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)