Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

join()

This alias of implode places a separator only between successive values.

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

Syntax

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

This alias of implode places a separator only between successive values. Empty fields still occupy positions, so a trailing empty field can leave a trailing separator. Use the single-array form for direct concatenation; the two-argument form takes the separator first. Pass a lone array by position. Naming it array: leaves the required first parameter $separator missing and raises ArgumentCountError.

Signature

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

Example output

["A::C:","XY","X"]

Examples

<?php
echo json_encode([join(":",["A","","C",""]),join(["X","Y"]),join(":",["X"])]);

Result

["A::C:","XY","X"]

Sources