我想将此symbol [ ]
添加到列"Post_images"
使用基础数据sql服务器
像这样,
“post_images” : “ht tp://img*sample*com/gambar1*jpg”, “ht tp://img*sample*com/gambar2*jpg”
至
“post_images” : [“ht tp://img*sample*com/gambar1*jpg”, “ht tp://img*sample*com/gambar2*jpg”]
json中的[]表示一组项。
假设您有一个数组,里面有两个字符串,那么调用json_encode(array)应该添加[]。
有关更多详细信息,请参见本教程。
http://www.tutorialspoint.com/json/json_php_example.htm
请不要自己写json。请改用php函数。
您必须为post_images
放置数组这意味着,如果你有$data,你json_encodeing
,你应该把你的帖子图像添加为子数组,而不是字符串。示例
$data = array(
'param1' => "data ...",
'post_images' => array(
“ht tp://img*sample*com/gambar1*jpg”,
“ht tp://img*sample*com/gambar1*jpg”
);
);
echo json_encode($data); // will output what you where looking for
执行以下操作:'["ht tp://imgsamplecom/gambar1*jpg","ht tp//imgsamplecom/gambar2*jpg"]'
示例:http://sqlfiddle.com/#!9/971279/1