TreeviewCopyright © aleen42 all right reserved, powered by aleen42

黏合

implode — 将一个一维数组的值转化为字符串
语法
  • string implode( string $glue, array $pieces)
  • string implode( array $pieces)
描述
  • 用 glue 将一维数组的值连接为一个字符串
  • implode() 可以接收两种参数顺序
参数
参数 描述
glue 默认为空的字符串
pieces 你想要转换的数组
返回值
  • 返回一个字符串,其内容为由 glue 分割开的数组的值
举例
// 示例1-传递两个参数
$array = ['this','is','an','example'];
$result = implode(',',$array);
echo $result;
// 结果
this,is,an,example
// 示例2-传递1个参数,可以看出默认glue为空字符串
$array = ['this','is','an','example'];
$result = implode($array);
echo $result;
// 结果
thisisanexample

join — 别名 implode()

results matching ""

    No results matching ""