爲什麼這隻給我最後一個值,而不是我的數據庫中的所有值?用foreach填充關聯數組php
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('ErpBundle:Sponsor');
$clients = $repo->findAll();
$array = array();
foreach ($clients as $key =>$client){
$array['id'] = $client->getId();
$array['value'] = $client->getName();
}
return $array