Re: Adding elements to an array
| From: | Joseph | Date: | Tue, 17 Jul 2001 10:14:17 +0000 |
| Subject: | Re: Adding elements to an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58240@lists.php.net to get a copy of this message | ||
Try
$MyArray = array('DATETIME' => $DateTime);
$MyArray["BUYVAL" ] = "1.23";
"Sharat Hegde" <shah@sonata-software.com> wrote in message
news:30402B4CB8C7D311A3C600C04F1513BC7E8976@bg2ipmail...
> Hello,
>
> I have a requirement to add elements to an associate array dynamically
based
> on some conditions. I initialize the array with the 1st associate array
> element
> $MyArray = array('DATETIME' => $DateTime);
>
> How do I add more elements to this associate array. I am using PHP 3 and
> array_merge and other functions for arrays are not supported in PHP3. I am
> trying the following:
> $MyArray[] = array("BUYVAL" => "1.23");
> but if I try and get the value of $MyArray[BUYVAL], I get nothing.
>
> I am sure this must be simple, but I do not seem to be getting it right!!
>
> Regards,
> Sharat Hegde
> Phone: 6560360 Ext 4680
>