PHP 字符串和数组 转换

除了serialize函数

explode 字符串到数组

$array=explode(separator,$string);

implode数组到字符串

如果是二维数组则只会把值放到字符串,
$string=implode(glue,$array);

示例:

[pcsh lang="php" tab_size="4" message="" hl_lines="" provider="manual"]

<?php
$arr = array('ab','cc','dd');
$brr = array('a'=>'ab','b'=>'cc','c'=>'dd',0=>'ee');
$temp1 = implode($arr);
$temp2 = implode($brr);

var_dump($temp1);
var_dump($temp2);

[/pcsh]

 

 

此处评论已关闭