array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.implode.php', 1 => 'implode', ), 'up' => array ( 0 => 'ref.strings.php', 1 => 'Funções de String', ), 'prev' => array ( 0 => 'function.htmlspecialchars.php', 1 => 'htmlspecialchars', ), 'next' => array ( 0 => 'function.join.php', 1 => 'join', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/strings/functions/implode.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
implode — Join array elements with a string
Alternative signature (not supported with named arguments):
Legacy signature (deprecated as of PHP 7.4.0, removed as of PHP 8.0.0):
Join array elements with a separator
string.
separator
Optional. Defaults to an empty string.
array
The array of strings to implode.
Returns a string containing a string representation of all the array elements in the same order, with the separator string between each element.
Versão | Descrição |
---|---|
8.0.0 |
Passing the separator after the array
is no longer supported.
|
7.4.0 |
Passing the separator after the array
(i.e. using the legacy signature) has been deprecated.
|
Exemplo #1 implode() example
<?php
$array = ['lastname', 'email', 'phone'];
var_dump(implode(",", $array)); // string(20) "lastname,email,phone"
// Empty string when using an empty array:
var_dump(implode('hello', [])); // string(0) ""
// The separator is optional:
var_dump(implode(['a', 'b', 'c'])); // string(3) "abc"
?>
Nota: Esta função é compatível com dados binários.