$array=explode(separator,$string);$string=implode(glue,$array);
$s1='Mon-Tue-Wed-Thu-Fri';$days_array=explode('-',$s1);$days_array 变量现在是一个有5个元素的数组,其元素 Mon 的索引为0,Tue 的索引为1,等等。$s2=implode(',',$days_array);$s2
<?php// 示例 1$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";$pieces = explode(" ", $pizza);echo $pieces[0]; // piece1echo $pieces[1]; // piece2// 示例 2$data = "foo:*:1023:1000::/home/foo:/bin/sh";list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);echo $user; // fooecho $pass; // *?>
<?php$str = 'one|two|three|four';// 正数的 limitprint_r(explode('|', $str, 2));// 负数的 limitprint_r(explode('|', $str, -1));?>
Array([0] => one[1] => two|three|four)Array([0] => one[1] => two[2] => three)
上一篇:PHP中图片等比例缩放的实例
下一篇:其实php分页没有想象的难