1
public function include_header($h, $h_data) {
// Require header file
if (isset($h) && !empty($h)) {
$this->header_file = 'includes/header/'.$h;
} else { return false; }
// Pass optional array of parameters
if (isset($h_data) && is_array($h_data) && !empty($h_data)) {
// Loop through array & assign keys to appropriate class members
foreach($h_data as $key => $val) {
if ($key == 'doctype') { $this->doctype = $val; }
if ($key == 'title') { $this->title = $val; }
if ($key == 'meta') {
// The meta key is should be an array in h_data
// so, we'll have to loop through the meta array
// in order to parse the individual meta elements.
foreach($key as $meta_key => $meta_val) {
$this->error = $meta_key;
}
}
}
} else { return false; }
}
나는 다음과 같은 변수가 다차원 배열을 통해 루프를 시도하고를 ... 작동하지의 PHP foreach 루프가 제대로
$ h_data [ '메타'] [ 'individual_element']
'메타'를 반복하려고하므로 개별 값에 액세스 할 수 있지만 문제가 있습니다. 도와주세요! 미리 감사드립니다!
귀하의 $ 발 걸을한다 각하지 $ 키 – Orangepill
는 foreach 루프가 제대로 작동하거나 도움 다중 통해 반복 필요하지의 중첩 차원 배열? 당신 문제는 무엇입니까? – bluegman991