php Array to string conversion
snippet in php

php Array to string conversion

user3727

Using implode() function in Php
-----------------------
Syntax
implode(separator,array);  

Example
<?php  
//assigning value to the array  
$dummyArr = array("Hello","Greppers,","Ankur","here !");  
  
echo implode(" ",$dummyArr);// Use of implode function  
?>  
  
Output:
Hello Greppers, Ankur here !

Array to String Conversion in PHP

user299

$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);

Notice: Array to string conversion php

user9079

// Use json_encode to collapse the array to json string:
$stuff = array(1,2,3);
print json_encode($stuff);   //Prints [1,2,3]

array to string conversion in php

user5762

$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"]}

Notice: Array to string conversion php

user5038

// 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);

arry to string php

user9372

implode("|",$type);