How to convert array to string in laravel?
easy way is using json_encode
and json_decode
php functions.
if you want to store an array in string column you can use:
$adprofile->education = json_encode($array);
and if you want to get that from DB and convert it back to an array use:
$array = json_decode($adprofile->education);
You can use php implode
for this or you can also use laravel collection for this.
heres the exmaple
collect([1, 2, 3, 4, 5])->implode('-');
// '1-2-3-4-5'
see documentation for this Implode
or you can use php function implode
see this
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
//Hello World! Beautiful Day!
print_r($request->education); //It is an array print
$str_json = json_encode($request->education); //array to json string conversion
echo $str_json; // printing json string
print_r(json_decode($str_json)); //printing array after convert json string to array
exit; // exiting further execution to check resutls