1Using implode() function in Php
2-----------------------
3Syntax
4implode(separator,array);
5
6Example
7<?php
8//assigning value to the array
9$dummyArr = array("Hello","Greppers,","Ankur","here !");
10
11echo implode(" ",$dummyArr);// Use of implode function
12?>
13
14Output:
15Hello Greppers, Ankur here !
1// Use json_encode to collapse the array to json string:
2$stuff = array(1,2,3);
3print json_encode($stuff); //Prints [1,2,3]
1// use the builtin php function print_r or var_dump:
2$stuff = array(1,2,3);
3print_r($stuff);
4$stuff = array(3,4,5);
5var_dump($stuff);
1$stuff = array(1,2,3);
2print_r($stuff);
3$stuff = array(3,4,5);
4var_dump($stuff);
1// Joining all the cells in the array together:
2<?php
3 $stuff = array(1,2,3);
4 print implode(", ", $stuff); //prints 1, 2, 3
5 print join(',', $stuff); //prints 1, 2, 3
6?>
1// suppress the Notices:
2error_reporting(0);
3print(array(1,2,3)); //Prints 'Array' without a Notice.