RE: [PHP] A problem with associative arrays..
| From: | Mark Roedel | Date: | Wed, 26 Jul 2000 20:36:24 +0000 |
| Subject: | RE: [PHP] A problem with associative arrays.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8404@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Rasmus Lerdorf [mailto:rasmus@php.net]
> Sent: Wednesday, July 26, 2000 3:20 PM
> To: Warren Vanichuk
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] A problem with associative arrays..
>
>
> Put single quotes around your array indices.
Would that really work?
If I say
$conf["db"] = "foo";
and then
$conf["db"]["host"] = "bar";
then is $conf["db"] a string, or is it an associative array? I know PHP's
highly flexible with typing 'n' stuff, but that really seems to be pushing
the limits...
For the record, even with quotes, I get similar results to what Warren
posted.
> On Wed, 26 Jul 2000, Warren Vanichuk wrote:
>
> >
> > Ok, I have just discovered that I cannot mix 'dimensions' in an
> associative
> > array.
> >
> > The source I have :
> >
> > <?php
> >
> > $conf[db] = "bazfoobar";
> > $conf[db][host] = "thishost";
> >
> > echo "value is: " . $conf[db] . "<br>";
> > echo "host is: " . $conf[db][host] . "<br>";
> >
> > $conf[db] = "foobarbaz";
> > $conf[db][host] = "somehost";
> >
> > echo "value is now : " . $conf[db] . "<br>";
> > echo "host is now : " . $conf[db][host] . "<br>";
> >
> > php?>
> >
> >
> > Generates :
> >
> > value is: tazfoobar
> > host is: t
> > value is now : soobarbaz
> > host is now : s
> >
> > Is this expected behaviour in PHP3? Can I actually do this in
> PHP4? Do I
> > have to ensure that all of my associative arrays have the exact same
> > dimensions?
> >
> > Suggestions? Hints? Valium? :)
> >
> > TIA.. :)
> >
> > Sincerely, Warren
> >
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>