Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

implode()

Join array values in iteration order with a separator and ignore their keys.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

implode(string $separator, array $array): string; implode(array $separator): string

Join array values in iteration order with a separator and ignore their keys. The one-array overload uses an empty separator. Empty input returns the empty string. PHP 8 no longer accepts the historical reversed two-argument order. Pass a lone array by position. Naming it array: leaves the required first parameter $separator missing and raises ArgumentCountError.

Signature

implode(string $separator, array $array): string; implode(array $separator): string

Example output

["B/A","BA",""]

Examples

<?php
$parts=["last"=>"B","first"=>"A"];
echo json_encode([implode("/",$parts),implode($parts),implode("/",[])],JSON_UNESCAPED_SLASHES);

Result

["B/A","BA",""]

Sources