0
이전에 실행 된 루프의 값을 가진 배열이 3 개 있습니다. 결과는 다음과 같다 :PHP는 모든 배열 키를 같은 값으로 변경합니다.
1. 변수 난
을 print_r의 경우 난Array
(
[0] = some id
[1] = some id
[2] = some id
[3] = some id
)
3. 변수 인 print_r 때
Array
(
[0] = some title
[1] = some title
[2] = some title
[3] = some title
)
2. 변수 인 print_r 때
Array ( [0] = some image [1] = some image [2] = some image [3] = some image )
Array
(
[0]=> Array
(
[Title] = title
[Id] = id
[Image] = image
)
[1]=> Array
(
[Title] = title
[Id] = id
[Image] = image
)
[2]=> Array
(
[Title] = title
[Id] = id
[Image] = image
)
)
나는 내가 통해 반복하는 동안 키를 제공하기 위해 노력
결과 :
지금 내가 나중에 그들을 결합하고이 결과를 가질 수 있도록 자신의 열쇠가 각 배열에 대해 원하는 하지만 루프 밖에서 나는 단 하나의 결과 만 얻었다. 이 예는 다음과 같습니다
$imgSource = array();
foreach($lists as $list) {
$tmp_dom->appendChild($tmp_dom->importNode($list,true));
$all_images = $list->getElementsByTagName('img');
foreach ($all_images as $image) {
if ($image->hasAttribute('src')) {
$imgSource['Title'] = $image->getAttribute('src');
}
if ($image->hasAttribute('data-lazy-src')) {
$lazyImageSource['Title'] = $image->getAttribute('data-lazy-src');
}
}
}
}
print_r($imgSource);
print_r($lazyImageSource);
키없이 내가 얻을 수있는 모든 요소 내가 전에을 보였다 방법 (1 - 3 변수) 그 후
나는이 있습니다
$combined = array_merge($uber, $nodes);
array_push($wohnungen, $combined);
이 내가 원하는 결과를 제공해야하지만, 키없이 그냥 같이 다른 후 배열 하나를 추가
Array
(
[0] = some title
[1] = some title
[2] = some title
[3] = some title
[4] = some id
[5] = some id
[6] = some id
[7] = some id
[8] = some image
[9] = some image
[10] = some image
[11] = some image
)
내가 충분히 철저했으면 좋겠어. 질문이 있으시면 언제든지 질문을 편집 할 수 있습니다. 사전
3. 배열에 예제가 있습니다. 다른 것들은 거의 같은 방법으로 만들어졌다. –