PHP工作笔记:数组转字符串与字符串转数组
2016-12-08 15:22
246 查看
一个数组要入库,发现不可以,特定用函数转为字符串入库
用“,”分割,并转为字符串
转换后的data效果:
把字符串按照分隔符切割出来使用:
$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);
相关文章推荐
- LAMP兄弟连原创视频教程(PHP笔记二--字符串,数组)
- PHP学习笔记2 - 文件、数组、字符串
- PHP学习笔记-1(变量、常量、类型、作用域、数组、字符串、大小写)
- php开发笔记(七)用数组函数实现生成随机字符串
- PHP工作笔记:遍历文件夹返回文件数组
- php学习笔记7-(数组操作)
- PHP数组回忆笔记--定位数组元素
- PHP学习笔记-->006 PHP数组
- 数字、浮点、布尔型、字符串和数组(php教程一)
- C++基础教程 学习笔记(二) 数组、字符串和指针
- 一篇不错的php数组学习笔记
- php使用js保存的json cookie 字符串,然后解析成数组,需要注意的事项
- LINQ 学习笔记-字符串数组与整数数组之间的转换,排序
- PHP学习笔记(2)-重要的数组[]
- c++学习笔记2——指向字符串的指针数组?
- php 将字符串按大写字母分隔成字符串数组
- php学习笔记2—(字符串和注释)
- PHP 工作笔记
- 学习php笔记 字符串处理
- PHP学习笔记-->003 PHP 字符串