0

我试图在我的多维数组中像这样:

$address = array();
while(!$res->EOF)
{
    $dataFromDB = array($res->fields['CODCLI'] => 
                     array(
                           "Address" => $res->fields['CIDCLI'].",".$res->fields['SIGUFS'].", USA", 
                           "Name"    => "SOMENAME")
                          );
    $address[]  = $dataFromDB;
    $res->MoveNext();
}

结果是这样的:

Array
 (
   [0] => Array
      (
        [28947] => Array
            (
                [Address] => PIRIPIRI,PI,USA
                [Name] => SOMENAME
            )
      )
 )

但我真正需要的是这样:

Array
(
  [1] => Array
    (
        [Address] => PIRIPIRI,PI,USA
        [Name] => SOMENAME
    )
)

我尝试了一些其他的东西,但没有任何帮助,我错过了什么?

4

1 回答 1

1

删除第一步,只需执行以下操作:

$address[]  = array(
   "Address" => $res->fields['CIDCLI'].",".$res->fields['SIGUFS'].", USA", 
   "Name"    => "SOMENAME"
);
于 2012-05-23T16:18:20.983 回答