You can use the PHP implode() or join() function for creating a string by joining the values or elements of an array with a glue string like comma (,) or hyphen (-).
Let's take a look at the following example to understand how it basically works:
<?php
$array = array("red", "green", "blue");
// Turning array into a string
$str = implode(", ", $array);
echo $str; // Outputs: red, green, blue
?>
Use the PHP
implode()orjoin()functionYou can use the PHP
implode()orjoin()function for creating a string by joining the values or elements of an array with a glue string like comma (,) or hyphen (-).Let's take a look at the following example to understand how it basically works:
need an explanation for this answer? contact us directly to get an explanation for this answer