php数组与字符串转换
来源:互联网 发布:linux加磁盘 编辑:程序博客网 时间:2024/06/06 09:16
1、将字符串转换成数组的几个函数:
(1)explode(separate,string)
示例:$str = "Hello world It's a beautiful day";
explode(" ",$str);//以空格为分界点
返回:array([0]=>"Hello",[1]=>"world",[2]=>"It's",[3]=>"a",[4]=>"beautiful",[5]=>"day")
(2)str_split(string,length) //length指每个数组元素的长度,默认情况下为1
示例:$str = "hello";
$a=str_split($str,3);
$b=str_split($str);
返回:a([0]=>"hel",[1]=>"lo") b([0]=>"h",[1]=>"e",[2]=>"l",[3]=>"l",[4]=>"o")
(3)unserialize(string)
反序列化,将已序列化的字符串返回到原数组形式。
2、将数组转换成字符串的几个函数:
(1)implode(separate,array) //explode的反向操作,separate默认为空字符
示例:$array = ('hello','world','!');
implode(" ",$array);
返回:"hello world !"
(2)serialize(array)
(1)explode(separate,string)
示例:$str = "Hello world It's a beautiful day";
explode(" ",$str);//以空格为分界点
返回:array([0]=>"Hello",[1]=>"world",[2]=>"It's",[3]=>"a",[4]=>"beautiful",[5]=>"day")
(2)str_split(string,length) //length指每个数组元素的长度,默认情况下为1
示例:$str = "hello";
$a=str_split($str,3);
$b=str_split($str);
返回:a([0]=>"hel",[1]=>"lo") b([0]=>"h",[1]=>"e",[2]=>"l",[3]=>"l",[4]=>"o")
(3)unserialize(string)
反序列化,将已序列化的字符串返回到原数组形式。
2、将数组转换成字符串的几个函数:
(1)implode(separate,array) //explode的反向操作,separate默认为空字符
示例:$array = ('hello','world','!');
implode(" ",$array);
返回:"hello world !"
(2)serialize(array)
序列化,将数组按照固定格式转换成字符串;
http://hi.baidu.com/sunweiliang/item/e4168f2e8c0f27c2ef10f1f4
0 0
- php数组与字符串转换
- php数组与字符串转换
- php数组与字符串的转换函数
- php数组与字符串的转换
- php的数组与字符串的转换函数整理汇总
- php的数组与字符串的转换函数整理汇总
- PHP实现url查询字符串与数组相互转换
- PHP explode() 字符串转换数组
- php 数组转换为字符串
- PHP字符串和数组转换
- php字符串数组相互转换
- 字符串与数组的转换
- 字符串与数组的转换
- 字符串与数组的转换
- 字符数组与字符串转换
- 字符串与数组的转换
- 数组与字符串间转换
- PHP对象与数组转换
- 浏览器工作原理
- cocos2d-x学习日志(1)--视角跟随主角
- 每个人心中都憧憬着属于自己的无限网络世界
- iOS 工程 copy 问题
- strut2文件上传,动态显示图片
- php数组与字符串转换
- Genymotion does not start Android virtual device
- ASP.NET大文件上传方法浅析
- Android 高仿QQ 界面滑动效果
- 使用事件驱动模型实现高效稳定的网络服务器程序
- 收藏:ASP.NET提供文件下载函数(支持大文件、续传、速度限制、资源占用小)
- ubuntu的init与系统服务设置
- android Activtity 之间传递对象的方法 application
- 黑马程序员---集合框架<泛型>