building dynamic 2d arrays?

From: Date: Sat, 04 Nov 2000 04:24:04 +0000
Subject: building dynamic 2d arrays?
Groups: php.general 
Request: Send a blank email to php-general+get-23678@lists.php.net to get a copy of this message
Greetings. I want to build an array of arrays. Each row in the array is an associative array with the form label => "text label", value = number This array is used by the PHPlib OOH Form to build a select list. Here is an example: $o = array( array("label"=>"Please Select","value"=>0), array("label"=>"Apple","value"=>1), array("label"=>"Orange","value"=>2), array("label"=>"Pear","value"=>3), array("label"=>"Grape","value"=>4) ); I want to fill in the 'text label' and number for each row from a database query (interbase). If I use the first code snippet below, I get a labels in my select menu, but the values (i.e., the label id in my database) is missing. This is because I have not followed the expected array format as shown above. $rs = array(); while ( list( $key, $value ) = ibase_fetch_row( $sth ) ) { $rs[$key] = $value; } If I try something like: $i=0; $rs = array(); while ( list( $key, $value ) = ibase_fetch_row( $sth ) ) { $i++; $rs[i] = array("label"=>"$value","value"=>$key); } I only end up with one row in my array. It does have the value, however. How can I do this? thanks Jeff -- jccann [at] home [dot] com

« previous php.general (#23678) next »