我关注
PHP add single quotes to comma separated list
将单引号添加到逗号分隔列表无法正常工作
$result = $data;
$str = "'" . implode ( "', '", $result ) . "'";
//result --- insert into `pharmacy`.`tblsales` ( Invoice_No ) values (I17-
07161)
// tried following
//$str = implode(";", $result); -- giving error :- Undefined
offset
//$str = "'" . implode ( "', '", $result ) . "'";-- same error :- Undefined
offset
//$str = implode("', '", $result); - same
$slice = explode(";", $str);
我可以修改更多内容以获得结果?
编辑:var_dump($ result)给出
array (size=35)
0 => string 'I17-07161' (length=9)
1 => string '06-11-2017' (length=10)
2 => string 'NAUSARAN MEDICOSE' (length=17)
3 => string 'SAHARANPUR' (length=10)
4 => string 'TTINA0065' (length=9)
5 => string 'ARBITEL CT 40' (length=13)
6 => string '10'S' (length=4)
7 => string '150' (length=3)
8 => string '0' (length=1)
9 => string '0' (length=1)
10 => string 'ARIS0004' (length=8)
11 => string '01-08-2017' (length=10)
12 => string '31-07-2019' (length=10)
13 => string 'ML-SIKKIM (ML24)' (length=16)
14 => string '61.4' (length=4)
15 => string '68.22' (length=5)
16 => string '95.5' (length=4)
17 => string '8,289.00' (length=8)
18 => string '-10' (length=3)
19 => string '-921' (length=4)
20 => string '0' (length=1)
21 => string '0' (length=1)
22 => string '0' (length=1)
23 => string '0' (length=1)
24 => string '0' (length=1)
25 => string '0' (length=1)
26 => string '0' (length=1)
27 => string '6' (length=1)
28 => string '497.34' (length=6)
29 => string '6' (length=1)
30 => string '497.34' (length=6)
31 => string '0' (length=1)
32 => string '0' (length=1)
33 => string '9,283.68' (length=8)
34 => string 'CC' (length=2)
答案 0 :(得分:1)
试试这个:
$result = explode(',', $_data);
$str = implode("','", $result );