모듈 배열에 몇 가지 옵션을 추가하는 데 문제가 있습니다. Opencart를 사용하고 있으며 이미지를 추가하여 모듈을 확장하려고합니다. 이를 수행하고 앞으로 코드를 손상시키지 않도록 보장하기 위해 배열을 바꾸는 대신 배열에 추가하고 싶습니다.PHP 배열 값 추가
이것은 내가 지금까지 가지고있는 코드 :
if (isset($this->request->post['special_module'])) {
$modules = $this->request->post['special_module'];
} elseif ($this->config->get('special_module')) {
$modules = $this->config->get('special_module');
}
$this->load->model('tool/image');
foreach ($modules as $module) {
if (isset($module['image']) && file_exists(DIR_IMAGE . $module['image'])) {
$image = $module['image'];
} else {
$image = 'no_image.jpg';
}
array_push($module, array(
'image' => $image,
'thumb' => $this->model_tool_image->resize($image, 100, 100)
));
}
print_r($modules);exit;
$this->data['modules'] = $modules;
인쇄 배열, 아니 이미지 또는 엄지 손가락 :
Array
(
[0] => Array
(
[image_width] => 307
[image_height] => 234
[layout_id] => 1
[position] => column_right
[status] => 1
[sort_order] => 1
)
)
내가 배열이 다시 할당해야 할 내가 array_push합니까?
브릴리언트, 그래서이 많이 나는 여전히 PHP로 배울 수있다. 참고 문헌에 대해 더 자세히 알기를 권하는 책/가이드가 있습니까? Google 검색을 할 때 PHP에 대한 실제 참조 정보를 찾을 수 있습니다. –
PHP 튜토리얼에서 찾을 수있는 대부분의 온라인 콘텐츠는 오래되어 나쁘고 (PHP 4 및 초기 5 초에 대해), 끔찍한 양질의 누락 및/또는 잘못 된 잘못된 것입니다. 특히 [w3fools] (http://w3fools.com)에서 어떤 것도 피하십시오. [PHP 사이트] (http://php.net)는 실제로 꽤 좋으며, 함수 참조 섹션의 주석은 종종 너무 유용합니다. –