variable array name

This is a discussion on variable array name within the PHP General forums, part of the PHP Programming Forums category; I seem to be having a problem in assigning a value to an array where the array is called dynamically. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-29-2007
Mark Head
 
Posts: n/a
Default variable array name

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
Reply With Quote
  #2 (permalink)  
Old 11-29-2007
Daniel Brown
 
Posts: n/a
Default Re: [PHP] variable array name

On Nov 29, 2007 7:47 AM, Mark Head <mark.head@assertia.com> 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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0