【发布时间】:2017-09-14 21:22:07
【问题描述】:
我有两个数组。我想在它们之间添加: 并将它们都添加到另一个数组中。
$temp = json_decode($csv[$indexLoc['allowance_json']], TRUE);
$details = is_array($temp)?(array_key_exists('details', $temp)?$temp['details']:''):'';
$anytime = is_array($temp)?(array_key_exists('anytime', $temp)?$temp['anytime']:''):'';
$deals[$counter]['deal_mins'] = $details .":". $anytime;
我需要上面的代码才能工作。
我也有基本的,总是有效的
$deals[$counter]['deal_mins'] = is_array($temp)?(array_key_exists('details', $temp)?$temp['details']:''):'';
这个可行,但我需要用: 分隔两个数组。
【问题讨论】:
-
错误?究竟是什么行不通?看起来不错。
-
数组不能用
:分隔。 -
你能尝试创建一个minimal reproducible example吗?这里有一些代码,很好,但我们确实需要至少查看一个输入示例、一个您尝试获得的输出示例以及一个您正在获得的示例。
-
他是否想根据这些值创建一个新的 JSON 对象?
-
好吧,我换个方式再解释一遍。