1
裏面我相信這個問題已經被問,但我不能找到它所以這裏去...返回整個陣列的一個值的最低值輔助陣列
我有這樣的代碼(必須使用PHP 5.3)
foreach ($array["Book"] as $abeBooks) {
$abeResult[$i] = array(
'itemCondition' => $abeBooks['itemCondition'],
'isbn13' =>$abeBooks['isbn13'],
'listingPrice' =>$abeBooks['listingPrice'],
'Link' =>$abeBooks['listingUrl'],
'sellerRating'=>$abeBooks['sellerRating'],
);
$isbn13[$i] = $abeBooks["isbn13"];
$itemCondition[$i] = $abeBooks["itemCondition"];
$sellerRating[$i] =$abeBooks['sellerRating'];
$Price[$i] = $abeBooks["listingPrice"];
$Link[$i] =$abeBooks['listingUrl'];
$i++; }
返回:
[{"itemCondition":"Fair","isbn13":"9780134167398","listingPrice":"123.5","Link":"www.abebooks.com\/servlet\/BookDetailsPL?bi=22403600014&cm_ven=sws&cm_cat=sws&cm_pla=sws&cm_ite=22403600014","sellerRating":"4"},{"itemCondition":"Very Good","isbn13":"9780134167398","listingPrice":"140.22","Link":"www.abebooks.com\/servlet\/BookDetailsPL?bi=22334428082&cm_ven=sws&cm_cat=sws&cm_pla=sws&cm_ite=22334428082","sellerRating":"4"},{"itemCondition":null,"isbn13":"9780134167398","listingPrice":"480.7","Link":"www.abebooks.com\/servlet\/BookDetailsPL?bi=22173609508&cm_ven=sws&cm_cat=sws&cm_pla=sws&cm_ite=22173609508","sellerRating":"4"}]
我想要做的是找到如果listingPrice最低,如果itemCondition是好,非常好,做工精細,或新的,並返回該項目離這個整個數組它將返回
({"itemCondition":"Fair","isbn13":"9780134167398","listingPrice":"123.5","Link":"www.abebooks.com\/servlet\/BookDetailsPL?bi=22403600014&cm_ven=sws&cm_cat=sws&cm_pla=sws&cm_ite=22403600014","sellerRating":"4"})
這給了我假的結果的輸出,如果我嘗試輸出結果我得到空括號 – ForgivenIT
@ForgivenIT噢,可能是因爲我不小心使用的對象符號,而不是陣列。我更新了答案。 –
我一直在摸索着如何用對象符號工作,以爲我錯過了一些感謝更新,爲我省下了一大筆頭痛 – ForgivenIT