PHP.nl

implode

implode

Join array elements with a string

string **implode** string $separator array $array

Alternative signature (not supported with named arguments):

string **implode** array $array

Legacy signature (deprecated as of PHP 7.4.0, removed as of PHP 8.0.0):

string **implode** array $array string $separator

Join array elements with a string. separator

separatorOptional. Defaults to an empty string.

arrayThe 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.

Voorbeeld: 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"

?>

explode``preg_split``http_build_query