배열을 통해 API에 공급할 항목 목록이 있지만 별도의 개체로 작성됩니다. 개체에있는 항목을 반복하여 배열에 공급할 수있는 변수를 구성 할 수 있다고 생각했지만 배열이 끊어졌습니다. 설명하는 것보다보기가 쉽습니다.변수에서 PHP 배열 설정
내가 사용하고있는 코드는 이것이다 :
//Set up the parser object
$parser = new XMLParser($xml);
$parser->Parse();
$skuList = '';
// Pull the inventory of the requested SKUs from Magento for comparison later
foreach($parser->document->product as $product)
{
$skuList .= "'" . $product->sku[0]->tagData . "',";
}
echo $skuList;
print_r($proxy->call($sessionId, 'product_stock.list', array(array($skuList))));
내가 명령 줄에서이 작업을 실행하면 내가 변수의 내용을 바꾸어 인 print_r 라인을 변경하면 나는 지금
'1DAFPOT5','8GAIL','26BULK30',Array
(
)
를 얻을 수 이 같은 전화에 직접
print_r($proxy->call($sessionId, 'product_stock.list', array(array('1DAFPOT5','8GAIL','26BULK30',))));
나는 어떤 결과를 얻었 는가?
'1DAFPOT5','8GAIL','26BULK30',Array
(
[0] => Array
(
[product_id] => 2154
[sku] => 26BULK30
[qty] => 19.0000
[is_in_stock] => 1
)
[1] => Array
(
[product_id] => 2255
[sku] => 8GAIL
[qty] => 16.0000
[is_in_stock] => 1
)
[2] => Array
(
[product_id] => 2270
[sku] => 1DAFPOT5
[qty] => 23.0000
[is_in_stock] => 1
)
)
변수를 잘못 구성했거나 배열에 다르게 공급해야합니까?
을, 어쩌면 도움이 : http://stackoverflow.com/q/7933982/367456 – hakre