Chose Language:
Author: Admin/Publisher |finished | checked

PHP implode

PHP implode function permit us convert an array into a String, but the term correct is that impode make a join between the array elements using a string as glue $glue and giving back a string as return.

This function receives 2 parameters, $glue and the $array.

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

To underestand in a better way lets see the array as it were train wagons,every wagon is an element,0,1,2 .., this wagon are not yet united, we need the train couplings to do that($glue),in this case all wagons unated will be the string returned.

Let’s make a little example, suppose we have a list of users and I need a list like: Luis, Gastón, Claudia, Jenie, Alexandra, etc.

implode example
$usuarios =array("Luis", "Gastón", "Claudia", "Jenie", "Alexandra");
$lista = implode(", ", $usuarios);
echo "$lista";
Luis, Gastón, Claudia, Jenie, Alexandra


Category: en-php
Something wrong? If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.
Last 4 post in same category