0
아래 개체에서 배열 안에 Cxyabc, Cxy123 및 Cxy234를 얻는 방법은 무엇입니까?SimpleXMLElement 배열 검색 문제
$xml_element = simplexml_load_string($xml,null, LIBXML_NOCDATA);
$childId = $xml_element->Parent->ChildID;
print_r(childId);
SimpleXMLElement Object (
[@attributes] => Array (
[entity] => result
[order-value] => 1
)
[0] => Cxyabc
[1] => Cxy123
[2] => Cxy234
)
답변을 주셔서 감사합니다. 문자열 변환이 필요합니다.
$test = array();
foreach($childId as $value){
$strValue = (string)$value;
array_push($test,$strValue);
}
하면 전체 코드를 게시 할 수 있습니까? 그러나'SimpleXMLElement'는'Traversable'을 구현하므로'foreach ($ instance-> children() $ node) {...}'를 사용하여 내부 컬렉션 인스턴스를 반복 할 수 있습니다. –
@Praveen : SimpleXML 개체입니다. 특수합니다. –
단순하지만 특별한 :) –