【发布时间】:2013-05-10 14:55:23
【问题描述】:
我有两个具有这种结构的变量:
$columns = "col1, col2, col3";
$values = "$value1, $value2, $value3";
我需要做什么才能获得:
$combined = "col1 = $value1, col2 = $value2, col3 = $value3";
我很确定我需要:
explode(',', $columns);
explode (',', $values);
$combined = array_combine($columns, $values);
$combined = implode(',', $combined);
但后来我得到:
$combined = "col1, $value1, col2, $value2, col3, $value3";
如何用“=”替换所有其他逗号?
这是最好的解决方法吗?
【问题讨论】:
-
给出 col1 = $value1 = col2 = etc...
-
就这样它消失了哈哈。
-
大声笑,对不起,我回复得太快了,然后我意识到我错了:)
-
否则使用循环有什么问题?
-
@HamZaDzCyberDeV 我该怎么做?它必须是 foreach 不是吗?