xxxxxxxxxx
// never print an array straight away
// so instead you so use foreach loop to get one by one
$ar = array(a,b,c);
foreach ($ar as $arr)
{
echo $arr
}
xxxxxxxxxx
// Use json_encode to collapse the array to json string:
$stuff = array(1,2,3);
print json_encode($stuff); //Prints [1,2,3]
xxxxxxxxxx
$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);
xxxxxxxxxx
$person = [
'name' => 'Jon',
'age' => 26,
'status' => null,
'friends' => ['Matt', 'Kaci', 'Jess']
];
echo json_encode($person);
// {"name":"Jon","age":26,"status":null,"friends":["Matt","Kaci","Jess"]}
xxxxxxxxxx
// use the builtin php function print_r or var_dump:
$stuff = array(1,2,3);
print_r($stuff);
$stuff = array(3,4,5);
var_dump($stuff);
xxxxxxxxxx
$array = array('apple', 'banana', 'orange');
$string = implode(', ', $array);
echo $string;
xxxxxxxxxx
$stuff = array(1,2,3);
print_r($stuff);
$stuff = array(3,4,5);
var_dump($stuff);
xxxxxxxxxx
// suppress the Notices:
error_reporting(0);
print(array(1,2,3)); //Prints 'Array' without a Notice.