PHP array to string comma, convert array element to string php
Example - How to cast array elements to strings in PHP?
<?php
$arrays = array('first name','last name', 'town', 'email', 'phone');
$comma_separated = implode(", ", $arrays);
echo $comma_separated ;
?>
The result:
first name, last name, town, email, phone
****************************************
Example - Easy way to turn a CSV file into a parseable array.
<?php
$str= "foo,bar,baz,bat";
$arr= explode(", ", $str);
print_r ($arr) ;
?>
The result:
Array
(
[0] => foo
[1] => bar
[2] => baz
[3] => bat
)
****************************************