Re: array_push

From: Date: Fri, 21 May 2004 12:15:32 +0000
Subject: Re: array_push
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-186667@lists.php.net to get a copy of this message
On Fri, 21 May 2004, Edward Peloke wrote: > > $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 > If you want to do it the way you're doing now you should do ik like this: array_push($clients, array($sql->getField('id')=>$sql->getField('fname'))); Another possible solution is like this: $clients[$sql->getField('id')] = $sql->getField('fname'); -- Jeroen There are only two kinds of programming languages: those people always bitch about and those nobody uses. -- Bjarne Stroustrup

« previous php.general (#186667) next »