PHP工作笔记:数组转字符串与字符串转数组
一个数组要入库,发现不可以,特定用函数转为字符串入库
$data = array( 'http://img4.bitautoimg.com/autoalbum/files/20110420/734/22494073435215_1565563_15.jpg', 'http://img4.bitautoimg.com/autoalbum/files/20110420/718/22494071876770_1565547_15.jpg', 'http://img2.bitautoimg.com/autoalbum/files/20110420/671/22494067187672_1565545_15.jpg' );
用“,”分割,并转为字符串
$data = array( 'http://img4.bitautoimg.com/autoalbum/files/20110420/734/22494073435215_1565563_15.jpg', 'http://img4.bitautoimg.com/autoalbum/files/20110420/718/22494071876770_1565547_15.jpg', 'http://img2.bitautoimg.com/autoalbum/files/20110420/671/22494067187672_1565545_15.jpg' ); $data = implode(",",$data);
转换后的data效果:
http://img4.bitautoimg.com/autoalbum/files/20110420/734/22494073435215_1565563_15.jpg,http://img4.bitautoimg.com/autoalbum/files/20110420/718/22494071876770_1565547_15.jpg,http://img2.bitautoimg.com/autoalbum/files/20110420/671/22494067187672_1565545_15.jpg
把字符串按照分隔符切割出来使用:
$newdata = explode(",",$data);