In this tutorial, we'll look at how to convert an array to a string in Laravel. To convert arrays to strings in Laravel, we use the Using implode() function.
The Implode () function
Laravel's implode function can be used to transform an array into a string. The implode() function is a built-in technique for creating a string from an array. Simply call this function from inside your controller method.
Example
<?php $array = array('Hello','am','a','Programmer'); $string = implode(" ",$array); echo $string; ?>
|
This code snippet will display the following String
Hello am a programmer |
Article Contributed By :
|
|
|
|
5586 Views |