PHP 新手教學 String | implode的使用說明

Table of Contents

Table of Contents

implode

將陣列轉成字串。別名為join

implode ( string $glue , array $pieces ) : string

implode ( array $pieces ) : string

Example:

$ints = array(1, 2, 3, 4, 5);
print_r(implode(",", $ints));
print_r(implode($ints));


$strings = array("a", "b", "c", "d", "e");
print_r(implode(" | ", $strings));
print_r(implode($strings));

Output:

// implode(",", $ints):
1,2,3,4,5

// implode($ints):
12345

// implode(" | ", $strings):
a | b | c | d | e

// implode($strings):
abcde

相關函數