我想不出一種方法來將其縮減為一個回圈。每個回圈中的處理是相同的。我會展示我嘗試過的東西,但我什至不知道該嘗試什么。
<?
if($xml->entry){
foreach ($xml->entry as $item) {
...
}
else{
foreach($rss->channel->item as $item) {
...
}
}
uj5u.com熱心網友回復:
foreach (($xml->entry ? $xml->entry : $rss->channel->item) as $item) {
...
}
uj5u.com熱心網友回復:
$items = $xml->entry ? $xml->entry : $rss->channel->item;
foreach( $items as $item ) {
...
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/398924.html
上一篇:如何僅在某些頁面上顯示頁腳按鈕?
