simpleXmlElement에서 새 배열을 작성하려고합니다. 나는 원하는 정보를 얻고 있으며 올바른 계층 구조가 아닙니다.다른 배열의 배열 구성
Array
(
[9522] => Array
(
[Mens Hats] => 44
)
[9522-NC-NO SIZE] => Array
(
[Mens Hats] => 44
)
[B287CSQU] => Array
(
[Boys] => 1
)
하지만
Array
(
[9522] => Array
(
[family] => Mens Hats
[classId] => 44
)
어떤 제안을합니다 :
$xmlNew1 = new SimpleXMLElement($responseNew1);
$test = array();
foreach ($xmlNew1->children() as $newChild){
$classIden[] = (string)$xmlNew1->class['id'];
$item[] = (string)$xmlNew1->code;
$family[] = (string)$xmlNew1->family;
for($i=0, $count = count($classIden); $i < $count; $i++) {
$test[$item[$i]][$family[$i]]= $classIden[$i];
}
}
print_r($test);
이 저를 준다? 감사!
모든 어린이를 불러내는 데 foreach가 필요하지 않습니까? –
@TylerNichol이 (가) 내 코드를 업데이트했습니다. –