Q:

php string to array


<?php

$arr = array('Hello','World!','Beautiful','Day!');

echo implode(" ",$arr);

?> 
3
print_r(explode(',',$yourstring));
0
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 !
3

<?php

$str = "Hello world. It's a beautiful day.";

print_r (explode(" ",$str));

?> 
0
$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);
1
$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"]}
0
implode("|",$type);
0

New to Communities?

Join the community