public function store($feed)
{
switch($feed)
{
case 'full':
$coupons = json_decode(file_get_contents('path-to-json-feed'), true);
break;
case 'incremental':
$coupons = json_decode(file_get_contents('path-to-different-json-feed'), true);
break;
}
var_dump($coupons);die();
$this->Deal_model->updateAllDeals($coupons);
echo 'Coupons Updated';
}
我正在尝试为分配一个值,$coupons
但var_dump($coupons)
返回一个空数组。
default
如果$feed
不是full
或,我建议您添加一个incremental
。
如果这是您的实际代码,则不确定是否存在一个名为的文件path-to-json-feed
,但似乎应该是其他文件,例如JSON文件/提要的实际路径。
替换path-to-json-feed
为实际文件,然后尝试使用下面的代码,看看会得到什么。
public function store($feed)
{
switch($feed)
{
case 'full':
$coupons = json_decode(file_get_contents('path-to-json-feed'), true);
break;
case 'incremental':
$coupons = json_decode(file_get_contents('path-to-json-feed'), true);
break;
default:
$coupons = json_decode(file_get_contents('path-to-json-feed'), true);
break;
}
var_dump($coupons);
die(); // DEBUGGING
$this->Deal_model->updateAllDeals($coupons);
echo 'Coupons Updated';
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句