Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá Pessoal,
Preciso percorrer o array abaixo:
Array ( [orders] => Array ( [17] => Array ( [orderid] => 17 [ordtoken] => 67a6f6bff50a34c90a75accf87ee5141 [ordcustid] => 604599 [orddate] => 1371760096 [ordlastmodified] => 1371760096 [ordsubtotal] => 99.0000 [ordtaxtotal] => 0.0000 [ordtaxrate] => 0.0000 [ordtaxname] => [ordtotalincludestax] => 0 [ordshipcost] => 35.0000 [ordshipmethod] => Frete [ordershipmodule] => [ordhandlingcost] => 0.0000 [ordtotalamount] => 134.0000 [ordstatus] => 0 [ordtotalqty] => 1 [ordtotalshipped] => 0 [orderpaymentmethod] => Boleto Banco caixa - SIGCB [orderpaymentmodule] => checkout_boletocaixasigcb [ordpayproviderid] => [ordpaymentstatus] => [ordrefundedamount] => 0.0000 [ordbillfirstname] => teste [ordbilllastname] => teste [ordbillcompany] => [ordbillstreet1] => testete [ordbillstreet2] => [ordbillsuburb] => teste [ordbillstate] => Paraná [ordbillzip] => 32423 [ordbillcountry] => Brasil [ordbillcountrycode] => BR [ordbillcountryid] => 30 [ordbillstateid] => 415 [ordbillphone] => 234232432 [ordbillemail] => testefds@hotmail.com [ordshipfirstname] => teste [ordshiplastname] => teste [ordshipcompany] => [ordshipstreet1] => testete [ordshipstreet2] => [ordshipsuburb] => teste [ordshipstate] => Paraná [ordshipzip] => 32423 [ordshipcountry] => Brasil [ordshipcountrycode] => BR [ordshipcountryid] => 30 [ordshipstateid] => 415 [ordshipphone] => 234232432 [ordshipemail] => testefds@hotmail.com [ordisdigital] => 0 [ordtrackingno] => [orddateshipped] => 0 [ordgatewayamount] => 134.0000 [ordstorecreditamount] => 0.0000 [ordgiftcertificateamount] => 0.0000 [ordinventoryupdated] => 0 [ordonlygiftcerts] => 1 [extrainfo] => a:1:{s:16:"giftcertificates";a:0:{}} [ordipaddress] => 189.31.206.244 [ordgeoipcountry] => Brasil [ordgeoipcountrycode] => BR [ordcurrencyid] => 1 [orddefaultcurrencyid] => 1 [ordcurrencyexchangerate] => 1.0000000000 [ordshippingzoneid] => 0 [ordshippingzone] => [ordnotes] => [ordcustmessage] => [ordvendorid] => 0 [ordformsessionid] => 90 [orddiscountamount] => 0.0000 ) ) [total] => 134 [gatewayamount] => 134.0000 [storecreditamount] => 0.0000 [giftcertificateamount] => 0.0000 [status] => 0 [currencyid] => 1 [customerid] => 604599 [isdigital] => 0 [paymentmodule] => checkout_boletocaixasigcb [paymentmethod] => Boleto Banco caixa - SIGCB [ipaddress] => 189.31.206.244 [extrainfo] => )
Preciso pegar os campos: orderid, ordtoken, orddate, ordcustid, ordpaymentstatus, quantida, total, etc ...
Alguem sabe como faço?
Você pode usar o foreach
Exemplo de uso:
$arrayExemplo = array(array("nome"=>"Ana", "idade"=>20), array("nome"=>"Maria", "idade"=>25), array("nome"=>"Jose", "idade"=>30));
foreach($arrayExemplo AS $row) {
echo $row["nome"]."<br/>";
echo $row["idade"]."<br/>";
echo "<hr/>";
}fiz o seguinte
foreach($this->pendingData AS $row) {
echo $row["orderid"]."<br/>";
}
porém aparece Notice: Undefined index: orderid in /home/flexsup/public_html/novo/includes/classes/class.order.php on line 53
Ta dificil. Alguém sabe como fazer?
Dê um [inline]var_export( $this->pendingData );[/inline] e poste o resultado.
tente assim:
<?php
$pedidos = Array ( 'orders' => Array ( '17' => Array ( 'orderid' => 17, 'ordtoken' => '67a6f6bff50a34c90a75accf87ee5141', 'ordcustid' => 604599, 'orddate' => 1371760096, 'ordlastmodified' => 1371760096, 'ordsubtotal' => 99.0000 , 'ordtaxtotal' => 0.0000 , 'ordtaxrate' => 0.0000 , 'ordtaxname' => 0 )));
foreach ($pedidos as $pedido){
foreach($pedido as $item){
echo $item['orderid'] .' - '. $item['ordtoken'] . ' - '. $item['ordsubtotal'];
}
}
Qualquer um destes resolve seu problema.