I have a array of string of stdClass objects but i am not able to parse the string correctly
I have tried various methods but all gives the same error of "get property of non-object"
foreach($response->Product->$x as $prod)
{
print $prod->Name;
print $prod->Price;
print $prod->Stock;
print $prod->SupplierName;
print $prod->CategoryName;
$x++;
}
//But my string coming in response is
stdClass Object (
[Product] => Array
( [0] => stdClass Object
( [Id] => 2 [Name] => Green Shirt [Price] => 1800 [Stock] => 50 [SupplierName] => Ali Yar [CategoryName] => Jeans )
[1] => stdClass Object
( [Id] => 7 [Name] => Red Shirt with Flowers [Price] => 2200 [Stock] => 40 [SupplierName] => Ali Yar [CategoryName] => Shirt )
[2] => stdClass Object
( [Id] => 8 [Name] => Red Shirt with Flowers [Price] => 2200 [Stock] => 40 [SupplierName] => Ali Yar [CategoryName] => Shirt )
[3] => stdClass Object
( [Id] => 9 [Name] => Check Shirt Yellow [Price] => 1100 [Stock] => 200 [SupplierName] => Ali Yar [CategoryName] => Shirt
)
)
)
I am getting these errors Trying to get property of non-object and Invalid argument supplied for foreach()