sunbird 发表于 2017-3-29 10:11:44

php 分割和合并数组函数

  1.php分割数组函数
  $str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
  输出:
  Array
(
=> Hello
=> world.
=> It's
=> a
=> beautiful
=> day.
)
  2.php合并数组函数
  $array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

echo $comma_separated; // lastname,email,phone

// Empty string when using an empty array:
var_dump(implode('hello', array())); // string(0) ""
页: [1]
查看完整版本: php 分割和合并数组函数