2016-02-23 53 views
1

我有一个映射到一个变量转换WSDL到阵列

$client = new SoapClient($wsdl, array("connection_timeout"=>10)); 

它返回像数组中的WSDL:

stdClass Object 
(
[getProductsReturn] => Array 
    (
     [0] => stdClass Object 
      (
       [barCode] => 5060285475448 
       [brandId] => 0 
       [childProductIds] => stdClass Object 
        (
        ) 

       [childProductIdsAsIntArray] => stdClass Object 
        (
        ) 

       [childProductIdsList] => 
       [fullProductPaths] => Candles->Amber And Lavender Scented Sachet 
       [fullProductPathsArray] => stdClass Object 
        (
        ) 

       [id] => 5883 
       [image] => 
       [imageId] => 0 
       [itemCount] => 1 
       [longDescription] => 
       [masterProductId] => 5883 
       [message] => 
       [messagePrice] => 0 
       [messageType] => 0 
       [optionId] => 0 
       [optionName] => null 
       [optionSetId] => 0 
       [optionSetName] => null 
       [orderType] => 5050 
       [parentProductCode] => 
       [parentProductId] => 8088 
       [price] => 2.99 
       [productCode] => AA2485 
       [productId] => 0 
       [productType] => 1010 
       [quantity] => 0 
       [quantityPrice] => 0 
       [rrp] => 2.99 
       [shortDescription] => Amber And Lavender Scented Sachet 
       [variation] => 
       [vatCodeDomainId] => 0 
       [wrappingPrice] => 0 
       [wrappingType] => 0 
      ) 

     [1] => stdClass Object 
      (
       [barCode] => 5060285475547 
       [brandId] => 0 
       [childProductIds] => stdClass Object 
        (
        ) 

       [childProductIdsAsIntArray] => stdClass Object 
        (
        ) 

       [childProductIdsList] => 
       [fullProductPaths] => Candles->Lavender And Bergamot Scented Sachet 
       [fullProductPathsArray] => stdClass Object 
        (
        ) 

       [id] => 5881 
       [image] => 
       [imageId] => 0 
       [itemCount] => 1 
       [longDescription] => 
       [masterProductId] => 5881 
       [message] => 
       [messagePrice] => 0 
       [messageType] => 0 
       [optionId] => 0 
       [optionName] => null 
       [optionSetId] => 0 
       [optionSetName] => null 
       [orderType] => 5050 
       [parentProductCode] => 
       [parentProductId] => 8088 
       [price] => 2.99 
       [productCode] => AA2484 
       [productId] => 0 
       [productType] => 1010 
       [quantity] => 0 
       [quantityPrice] => 0 
       [rrp] => 2.99 
       [shortDescription] => Lavender And Bergamot Scented Sachet 
       [variation] => 
       [vatCodeDomainId] => 0 
       [wrappingPrice] => 0 
       [wrappingType] => 0 
      ) 

我想在一个HTML展现这一点,这就是我在已经给出的循环:

<pre> 
foreach ($product as $products) { 
    $currentStockQuantity = $product->barCode($products); 
    echo $currentStockQuantity; 
    echo $products->barCode; 
    echo $products[$i]->shortDescription; 
    echo $products[$i]->barCode; 
    $i++; 
} 

但它没有显示所有的产品中,有大约100产品,但只有一个是显示在此刻

+1

在您发布,我们不能看到for循环的代码你因此在这一点上找到错误是不可能的。只要它显示第一个元素,显示数据的概念是可以的,但是你的问题似乎在循环中。请根据https://stackoverflow.com/help/mcve发布代码,以便我们重现错误。 – R4PH43L

回答

0

假设你存储在一个$products变量您的WSDL结果数组,你可以尝试:

foreach ($products as $product) { 
    echo $product->shortDescription; 
    echo $product->barCode; 
    // ... and whatever you want 
} 

更多的foreach信息:http://php.net/manual/en/control-structures.foreach.php