使用 laravel json 导入双引号
to import double quotes with laravel json
当前记录;
["ss,bb,nn"]
想保存如下;
["ss","bb","nn"]
我的模型;
protected $casts = [
'options' => 'array',
];
我的控制器;
$cpoll->options = $request->options;
使用这个:
$data = ["ss,bb,nn"];
$data2 = explode(',',$data[0]);
您可以同时使用内爆和爆炸来获得结果。将其分配给变量并进行处理然后导入
从数组中删除大括号
$myString =["ss,bb,nn"];
$string = implode('', $myString);
用逗号(,)分解
$myArray = explode(',', $string );
所以最终代码将是
$myString = ["ss,bb,nn"];
$string = implode('', $myString);
$myArray = explode(',', $string);
return $myArray;
当前记录;
["ss,bb,nn"]
想保存如下;
["ss","bb","nn"]
我的模型;
protected $casts = [
'options' => 'array',
];
我的控制器;
$cpoll->options = $request->options;
使用这个:
$data = ["ss,bb,nn"];
$data2 = explode(',',$data[0]);
您可以同时使用内爆和爆炸来获得结果。将其分配给变量并进行处理然后导入
从数组中删除大括号
$myString =["ss,bb,nn"]; $string = implode('', $myString);
用逗号(,)分解
$myArray = explode(',', $string );
所以最终代码将是
$myString = ["ss,bb,nn"];
$string = implode('', $myString);
$myArray = explode(',', $string);
return $myArray;