내가 사용하지 않는 자동차의 나머지 (아우디와 도요타)이 마지막 기능에 표시 될 것입니다 필요가 내가PHP 배열 - 표시되지 않는 바르
<?php
$type[ford][focus] = 'some text';
$type[ford][fiesta] = 'some text';
$type[toyota][corola] = 'some text';
$type[toyota][avensis] = 'some text';
$type[bmw][x6] = 'some text';
$type[bmw][x5] = 'some text';
$type[audi][a6] = 'some text';
$type[audi][a8] = 'some text';
function show($car){
foreach ($car as $model)
{
echo $model;
}
}
echo 'Best cars';
show ($type[bmw]);
echo 'Other cars';
show ($type[ford]);
?>
이 있다고 할 수 있습니다. 따라서 show ($ type [ford])는 ford, audi 및 toyota 자동차를 표시해야합니다.
미리 감사드립니다.
** 문자열 인 경우 배열 키를 인용하십시오. 오류보고를 활성화 한 경우 볼 수 있듯이 **'$ type [ford]'가 잘못되었습니다. 그것은'$ type [ 'ford']'이어야합니다. – deceze
@LoWE : 재귀를 이해합니까? 그렇다면 [is_array()] (http://php.net/manual/en/function.is-array.php) 만 있으면됩니다. 그렇지 않다면 [this] (http://www.elated.com/articles/php-recursive-functions/)와 같은 기사를 읽으십시오. –
@ André : 나는이 질문을 완전히 오해했을 것입니다. 그러나 재귀가이 문제와 관련이 있는지 알지 못합니다. – JJJ