How to join array elements into a string in PHP

3 Answers

0 votes
$array = array('php', 'c', 'java');
$s = implode(" , ", $array);
echo $s;

/*
run:

php , c , java 

*/

 



answered Jun 29, 2016 by avibootz
0 votes
$arr = array('1', '2', '3', '4', '5');
$s = join('<br />', $arr);
echo $s;

/*
run: 

1
2
3
4
5 

*/

 



answered Jul 2, 2016 by avibootz
0 votes
$arr = array('1', '2', '3', '4', '5');
$s = implode('<br />', $arr);
echo $s;

/*
run: 

1
2
3
4
5 

*/

 



answered Jul 2, 2016 by avibootz

Related questions

2 answers 198 views
2 answers 215 views
1 answer 150 views
1 answer 135 views
1 answer 164 views
2 answers 266 views
...