Re: Need help with this array
| From: | Jim Lucas | Date: | Mon, 21 Apr 2003 19:54:38 +0000 |
| Subject: | Re: Need help with this array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144709@lists.php.net to get a copy of this message | ||
each time you do this
$default_peeps[]
it increments the index of the array by 1.
so doing something like this would be better.
$default_peeps = array();
while ($peeps_row = $peeps_result->fetchRow(DB_FETCHMODE_ASSOC)){
$default_peeps[$peeps_row['person_id']] = $peeps_row;
}
this will give you a single diamention array that has the person_id as the
key and the values will be stored in an array. then access them like this.
echo $default_peeps[1]['persons_name'];
Jim
----- Original Message -----
From: "Charles Kline" <ckline@rightcode.net>
To: <php-general@lists.php.net>
Sent: Monday, April 21, 2003 12:39 PM
Subject: [PHP] Need help with this array
> I have an array which is created (perhaps incorrectly?) like this:
>
> $default_peeps = array();
> while ($peeps_row = $peeps_result->fetchRow(DB_FETCHMODE_ASSOC)){
> $default_peeps[] = $peeps_row['person_id'];
> $default_peeps[][] = $peeps_row['is_primary'];
> }
>
> When I print_r() the array I get this:
>
> Array ( [0] => 1649815377 [1] => Array ( [0] => N ) [2] => 890812244
> [3] => Array ( [0] => N ) [4] => -408244191 [5] => Array ( [0] => Y ) )
>
> I am able to get the first value (person_id) like this:
>
> echo $default_peeps[0];
>
> But I am not sure how to get the other part (N) for that person - the
> value of is_primary
>
> Thanks for any pointers.
>
> charles
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>