how to solve array to string conversion error in php code example
Example 1: php Array to string conversion
Using implode() function in Php
-----------------------
Syntax
implode(separator,array);
Example
<?php
$dummyArr = array("Hello","Greppers,","Ankur","here !");
echo implode(" ",$dummyArr);
?>
Output:
Hello Greppers, Ankur here !
Example 2: array to string conversion in php
$person = [
'name' => 'Jon',
'age' => 26,
'status' => null,
'friends' => ['Matt', 'Kaci', 'Jess']
];
echo json_encode($person);
Example 3: Notice: Array to string conversion php
$stuff = array(1,2,3);
print_r($stuff);
$stuff = array(3,4,5);
var_dump($stuff);
Example 4: Notice: Array to string conversion php
error_reporting(0);
print(array(1,2,3));