implode
Description
Syntax
implode(
string $separator,
array $array
): stringimplode(
array $array
): stringParameters
separator
Optional. Defaults to an empty string.
array
The array of strings to implode.
Return
Returns a string containing a string representation of all the array elements in the same order, with the separator string between each element.
Examples
1 · array
<?
$array =
[
"1",
"2",
"3"
];
$return = implode($array);
var_dump($return);
string(3) "123"
2 · separator array
<?
$separator = ",";
$array =
[
"1",
"2",
"3"
];
$return = implode($separator, $array);
var_dump($return);
string(5) "1,2,3"
3 · empty
<? $separator = ","; $array = []; $return = implode($separator, $array); var_dump($return);
string(0) ""
Links
String
- addcslashes
- addslashes
- bin2hex
- chop
- chr
- chunk_split
- convert_uudecode
- convert_uuencode
- count_chars
- crc32
- crypt
- echo
- explode
- fprintf
- get_html_translation_table
- hebrev
- hebrevc
- hex2bin
- html_entity_decode
- htmlentities
- htmlspecialchars
- htmlspecialchars_decode
- join
- lcfirst
- levenshtein
- localeconv
- ltrim
- md5
- md5_file
- metaphone
- nl_langinfo
- nl2br
- number_format
- ord
- parse_str
- printf
- quoted_printable_decode
- quoted_printable_encode
- quotemeta
- rtrim
- setlocale
- sha1
- sha1_file
- similar_text
- soundex
- sprintf
- sscanf
- str_contains
- str_decrement
- str_ends_with
- str_getcsv
- str_increment
- str_ireplace
- str_pad
- str_repeat
- str_replace
- str_rot13
- str_shuffle
- str_split
- str_starts_with
- str_word_count
- strcasecmp
- strchr
- strcmp
- strcoll
- strcspn
- strip_tags
- stripcslashes
- stripos
- stripslashes
- stristr
- strlen
- strnatcasecmp
- strnatcmp
- strncasecmp
- strncmp
- strpbrk
- strpos
- strrchr
- strrev
- strripos
- strrpos
- strspn
- strstr
- strtok
- strtolower
- strtoupper
- strtr
- substr
- substr_compare
- substr_count
- substr_replace
- trim
- ucfirst
- ucwords
- vfprintf
- vprintf
- vsprintf
- wordwrap