خرید بک لینک
I'm so confused with multidimensional arrays. May I please ask a couple questions?

1.) In the json array below, How do I use PHP to echo, for example, the price offered by Susan?

I tried things like echo $result["data"][0]["Susan"] to work, but it won't work.

2.) Near the top of the array it shows the lowest price is $25.56. How do I get PHP to echo that?

Again, I tried echo $result[LowestPrice] but that doesn't work.

3.) The array below is really big. What code do I use to create a smaller array of just [Name] and [OfferingPrice] ??

If I can do that, then I can do the PHP thing where you go "foreach ($result as $var=>$value) { echo "$var...$value" } etc., and I can sort it etc.

Here's the array:

$result = json_decode($stuff,true);
print_r($result);

//this is what it is output

Array
(
[data] => Array
(
[Info] => Array
(
[LowestPrice] => 25.56
[PlaceOfManufacture] => USA
)

[OfferingPrice] => Array
(
[0] => Array
(
[OfferingPrice] => 20.00
[SalesAssociate] => Array
(
[BadgeNumber] => 125
[Name] => Fred
)

)

[1] => Array
(
[OfferingPrice] => 18.36
[SalesAssociate] => Array
(
[BadgeNumber] => 932
[Name] => Susan
)

)

[2] => Array
(
[OfferingPrice] => 2.34
[SalesAssociate] => Array
(
[BadgeNumber] => 73
[Name] => Grandpa
)

)

[3] => Array
(
[OfferingPrice] => 44.28
[SalesAssociate] => Array
(
[BadgeNumber] => 202
[Name] => Stewart
)

)

)

)

)

برچسب: نویسنده: آیلین رضوانی تاريخ: شنبه 18 شهريور 1396 ساعت: 4:26

صفحه بندی