【发布时间】:2013-06-18 06:16:41
【问题描述】:
我有一个这样的条件字符串:
echo $cnd = "'use_funds'=>'no'";
而我的$data 数组是:
$data = array(
$cnd,
'quantity' => $_POST['qty_' . $q],
'veg_name' => $_POST['veg_name_' . $q],
'rate' => $_POST['rate_' . $q],
'ws_price' => $_POST['ws_price_' . $q],
'ret_price' => $_POST['ret_price_' . $q],
'mop' => $_POST['mop_' . $q],
'ret_margin' => $_POST['ret_margin_' . $q]
);
上面的echo $cnd 显示'use_funds'=>'no',但var_dump($data) 显示array
0 => string ''use_funds'=>'no'' (length=17)。因为它是一个字符串,所以我的数据没有插入到我的表中。如何将$cnd 设为关联数组元素而不是字符串?
【问题讨论】:
-
为什么
$cnd包含PHP代码?像$use_funds = 'no'这样的东西不是更有意义吗?
标签: php arrays string associative-array