Php 我通过soap api获取数据,希望以组vise的形式显示

Php 我通过soap api获取数据,希望以组vise的形式显示,php,magento,soap,Php,Magento,Soap,我有这个SOAP API代码 $getstatus="complete"; $thedate = date("Y-m-d", strtotime("6 month ago")); $thesearch =array(array('updated_at'=>array('from'=>"$thedate"), 'status'=>array('eq'=>$getstatus))); $totolsale = $soap->call($session_id, 'sa

我有这个SOAP API代码

$getstatus="complete";
$thedate = date("Y-m-d", strtotime("6 month ago"));
$thesearch =array(array('updated_at'=>array('from'=>"$thedate"),   'status'=>array('eq'=>$getstatus)));
$totolsale = $soap->call($session_id, 'sales_order.list', $thesearch);

 if( is_array( $totolsale ) && !empty( $totolsale )) { 

// For every time there's a entry in the array we wish to run a loop
foreach( $totolsale as $sales ) 
{
 echo "<tr>";
       echo "<td style=\"color:#FF0000;\">".date('Y-m-d',strtotime($sales['created_at']))."</td>";
       echo "<td style=\"color:#FF0000;\">".$sales['base_grand_total']."</td>";
     echo "</tr>";

   }
 }

 //// Result is as follow/////

    Date        Qty     Amount      
    2013-12-12  1.00    109.0000    
    2013-12-13  1.00    109.0000    
    2013-12-14  2.00    150.0000    
    2013-12-16  1.00    109.0000    
    2013-12-16  1.00    109.0000    
    2013-12-18  1.00    109.0000    
    2014-01-25  1.00    109.0000    
$getstatus=“完成”;
$thedate=日期(“Y-m-d”,标准时间(“6个月前”);
$thesearch=array(array('updated_at'=>array('from'=>“$thedate”),'status'=>array('eq'=>$getstatus));
$totolsale=$soap->call($session\u id,'sales\u order.list',$thesearch);
如果(是数组($totalsale)&&!空($totalsale)){
//每当数组中有一个条目时,我们都希望运行一个循环
foreach($totolsale作为$sales)
{
回声“;
日期('Y-m-d',标准时间($sales['created_']));
echo.“$sales['base_grand_total'”;
回声“;
}
}
////结果如下/////
日期数量金额
2013-12-12  1.00    109.0000    
2013-12-13  1.00    109.0000    
2013-12-14  2.00    150.0000    
2013-12-16  1.00    109.0000    
2013-12-16  1.00    109.0000    
2013-12-18  1.00    109.0000    
2014-01-25  1.00    109.0000    

这是所有订单列表日期虎钳,但我想显示每个日期组虎钳的总销售额。像2013-12-16一样,它有两个记录,但我想在一行中显示它在这个日期的总销售额,而不是作为列表

前7天的解决方案如下

  $truecats = array();
foreach ($totolsale as $sales) {
 if (!isset($truecats[date('Y-m-d',strtotime($sales['created_at']))])) {
    $truecats[date('Y-m-d',strtotime($sales['created_at']))] = array();
}
$truecats[date('Y-m-d',strtotime($sales['created_at']))][] =  $sales['base_grand_total'];
}



foreach ($truecats as $dates => $values) 
{
        $totdailysale=0;

 /// if day is empty then take it as 

        for($i=1;$i<=7;$i++)
        {


            $datenow=date ('Y-m-d', strtotime ( '-'.$i. 'day' . $date ) ); 

            if($dates==$datenow)
            {
           echo "<tr><td>$dates</td>";

           foreach ($values as $val) 
           {
               $totdailysale+=$val;
             // echo "<td>$totdailysale</td></tr>";
           }
            echo "<td>$totdailysale</td></tr>";
        }
        else
        {
          echo "<tr><td>$datenow</td><td>0</td></tr>";  

        }




    }
    }
$truecats=array();
foreach($totolsale作为$sales){
如果(!isset($truecats[日期('Y-m-d',strottime($sales['created_']))])){
$truecats[date('Y-m-d',strottime($sales['created_at'])]]=array();
}
$truecats[日期('Y-m-d',strottime($sales['created_'at'))][]=$sales['base_grand_total'];
}
foreach($truecats作为$dates=>$value)
{
$totdailysale=0;
///如果一天是空的,那么就把它当作一天
对于($i=1;$i)