[英]PHP - Array getting empty outside foreach loop
Hi I have a below code in opencart (responsible to display payment options in checkout step - 4), 嗨,我在opencart中有以下代码(负责在结帐步骤-4中显示付款选项),
$method_data = array();
$results = $this->model_setting_extension->getExtensions('payment');
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('payment/' . $result['code']);
$method = $this->{'model_payment_' . $result['code']}->getMethod($payment_address, $total);
if ($method) {
$method_data[$result['code']] = $method;
}
}
print_r($method_data); // Getting dump of data's
}
print_r($method_data); // Empty Array
I've checked all possible combinations for this issue like, 我已经检查了此问题的所有可能组合,例如,
Did anyone have any idea on what's happening behind this issue. 有没有人对这个问题背后发生的事情有任何想法。
Can you please check once again with the following code : 您能否使用以下代码再次检查:
if ($method) {
$method_data[][$result['code']] = $method;
}
It will make the array two dimensional. 它将使数组成为二维的。 Please check and let me know if you need any help further.
请检查并告知我是否需要进一步的帮助。
NOTE : Seems the code in CI. 注意:似乎在CI中的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.