array_push

From: Date: Fri, 21 May 2004 12:03:30 +0000
Subject: array_push
Groups: php.general 
Request: Send a blank email to php-general+get-186666@lists.php.net to get a copy of this message
Ok, I am having a brain cramp for some reason but I need to pass in an array to my form class to build select boxes. The array is ("id"=>"John Doe"), I need to dynamically build this array from a query but I am getting errors using array_push.do I need to use array_merge? Example: $sql=new Database(); $sql->query("select fname,lname, id from clients"); $clients[]=array(); while($sql->nextRecord()){ array_push($clients, $sql->getField('id')=>$sql->getField('fname')); } // while Parse error: parse error, unexpected T_DOUBLE_ARROW in C:\obox\Apache2\htdocs\nh_vacdest\admin\test.php on line 38 How can I dynamically create my array? Thanks, Eddie

« previous php.general (#186666) next »