comments
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): stringSyntax
implode($glue,$array);
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<?php $usuarios =array("Luis", "Gastón", "Claudia", "Jenie", "Alexandra"); $lista = implode(", ", $usuarios); echo "$lista"; ?>
Luis, Gastón, Claudia, Jenie, Alexandra
Reference: php.net
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