php数组与字符串转换
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)
序列化,将数组按照固定格式转换成字符串;
php数组与字符串转换的更多相关文章
- php byte数组与字符串转换类
<?php /** * byte数组与字符串转化类 * @author ZT */ class Bytes { /** * 转换一个string字符串为byte数组 * @param $str ...
- php数组和字符串转换
PHP 中由于数组和字符串这两种变量类型是如此常用,以至于 PHP 具有两个函数,可以在字符串和数组之间互相进行转换. $array=explode(separator,$string); $stri ...
- JSON数组不用字符串转换的写法
var organization = []; //机构组织 //初始化用户数据列表中用户机构列的数据源 admin.ajax("GetOrganizationInfo", null ...
- C#字节数组与字符串转换
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- JavaScript学习笔记3之 数组 & arguments(参数对象)& 数字和字符串转换 & innerText/innerHTML & 鼠标事件
一.Array数组 1.数组初始化(Array属于对象类型) /*关于数组的初始化*/ //1.创建 Array 对象--方法1: var arr1=[]; arr1[0]='aa';//给数组元素赋 ...
- Java将一段逗号分割的字符串转换成一个数组
String 类:String 类代表字符串.Java 程序中的所有字符串字面值都作为此类的实例实现.字符串是常量,它们的值在创建之后不能更改.字符串缓冲区支持可变的字符串.因为 String 对象是 ...
- C# 16进制与字符串、字节数组之间的转换(转)
1.请问c#中如何将十进制数的字符串转化成十六进制数的字符串 //十进制转二进制 Console.WriteLine("十进制166的二进制表示: "+Convert.ToSt ...
- android112 jni 把java的字符串转换成c的字符串,数组处理
package com.itheima.charencode; import android.os.Bundle; import android.app.Activity; import androi ...
- C#编程中的Image/Bitmap与base64的转换及 Base-64 字符数组或字符串的长度无效问题 解决
最近用base64编码传图片遇到了点问题,总结下. 首先总结下base64编码的逻辑,来自网络:https://www.cnblogs.com/zhangchengye/p/5432276.html ...
随机推荐
- js对table操作(添加删除交换上下TR)
<table width="100%" border="0" cellpadding="2" cellspacing="1& ...
- node-sass 安装失败win32-x64-48_binding.node
升级了nodejs的版本,原项目的node-sass模块启动安装不了. 下载对应的win32-x64-xx_binding.node https://github.com/sass/node-sass ...
- 微信小程序引入外部js 方法
步骤: 1.首先将外部js放在你指定的文件夹里(这都是废话...) 2.接下来 将该js文件中你要使用的方法给暴露出来 3.在您要使用的js中引入该js 4.使用暴露出来的方法 例子:使用md5加密 ...
- Eclipse 创建新的workspace
工具:eclipse 版本:4.5.1 1.配置jdk(java-Compiler).maven(Mven-User Settings) 2.从svn拉取项目,创建.project(修改其项目名称) ...
- uuid.js
// On creation of a UUID object, set it's initial valuefunction UUID(){ this.id = this.createUUID ...
- [SoapUI] Read data from response , use it to update parameter
import com.eviware.soapui.support.GroovyUtils def groovyUtils = new GroovyUtils( context ) def holde ...
- GYM 100741A Queries
传送门 题目大意: 一个长度为n的序列,q次三种操作 +p r:下标为p的数+r -p r:下标为p的数-r s l r mod [L,R]中有多少数%m=mod,m已经给出 题解: 开十个树状数组 ...
- 【211】win10快捷键大全
参考:win10快捷键大全 win10常用快捷键 • 贴靠窗口:Win +左/右> Win +上/下>窗口可以变为1/4大小放置在屏幕4个角落 • 切换窗口:Alt + Tab(不是新的, ...
- A. Bus to Udayland
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- c++ 头文件 及 sort 和 vector简单介绍
c++ sort :http://www.16kan.com/post/997260.html http://wenku.baidu.com/view/e064166daf1ffc4ffe47ac6 ...