我最近想出了一個相當討厭的問題。一個陣列內的元素相結合給我留下了雙陣列:結合PHP數組出條件和foreach循環
$w_invoices = array();
if($w_invoices_get['numreturned'] == '1')
{
$w_invoices[] = $w_invoices_get['invoices']['invoice']['id'];
// Just put $w_invoices_get array element into $w_invoices array
}
else
{
foreach($w_invoices_get['invoices']['invoice'] as $key=>$w_invoice_id)
{
$w_invoices[] = $w_invoice_id['id'];
// Acquire array's array element into $w_invoices array
}
}
print_r
顯示: Array ([0] => 1 [1] => 2) Array ([0] => 4)
但我想這是一個數組
如果你不解釋$ w_invoces_get – edi9999
的結構,我認爲我們不能提供幫助。你能重建一個更清晰的結構嗎!有些數據是模糊的,只是萌芽。 –
執行'$ w_invoices_get ['invoices'] ['invoice'] ['id']'和'$ w_invoice_id ['id']''var_dump''。它看起來像其中一個是一個數組。 –