array to string php

60

array to string php -

<?php

$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

echo $comma_separated; 

// lastname,email,phone


?>

Array to String Conversion in PHP -

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

Convert an Array to a String in PHP -

phpCopy<?php
   $array = ["Lili", "Rose", "Jasmine", "Daisy"];
   $JsonObject = json_encode($array);
   echo "The array is converted to the Json string.";
   echo "\n"; 
   echo"The Json string is $JsonObject";
?>

Convert an Array to a String in PHP -

phpCopy<?php
   $array = ["Lili", "Rose", "Jasmine", "Daisy"];
   $JsonObject = serialize($array);
   echo "The array is converted to the Json string.";
   echo "\n"; 
   echo"The Json string is $JsonObject";
?>

convert numeric array to string array php -

$integerIDs = array_map('intval', explode(',', $string));

Comments

Submit
0 Comments