get the sub index in foreach loop in simpleXMLElement

后端 未结 5 1068
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 13:38


  
    This is title1
    This is desc1         


        
5条回答
  •  Happy的楠姐
    2020-12-19 14:25

    You could use SimpleXMLElement::xpath to return an array of the elements, then access the array's keys as you want.

    foreach ($xml->xpath('/items/item') as $key => $item) 
    

提交回复
热议问题