Re: [PHPLIB] variable array key From: Darryl Ross (djr <email protected>)
Date: 03/05/00

On Sun, 5 Mar 2000, Chester McLaughlin wrote:

> I know I've seen this before, but I can't find an example of it
> anywhere.
> I would like to have an array whose key's are set dynamically.
>
> For instance...
>
> while ($dbn->next_record()) {
> $question_pres = $dbn->f("question_pres");
> $answer = $dbn->f("answer");
> $front_page = array($question_pres => $answer);
> }//end while

This might work:
$front_page[$question_pres] = $answer;

>
> this works, but it overwrites $front_page every time. I tried
> $front_page[] but that created a multidimensional array, which I don't
> want. how can I dynamically set the key to the value of "$question_pres"
> instead of 0,1,2,3,4,5 ect.
>
> -
> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> the body, not the subject, of your message.
>

________________________________________________________________
   Darryl Ross <djr <email protected>> Cybersource Pty. Ltd.
     Web/Database Integration and Development
+61 3 9642 5997 Level 8, 140 Queen Street, Melbourne Australia

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.