DekGenius.com
PHP
array to string php
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated;
// lastname,email,phone
?>
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 "
";
echo"The Json string is $JsonObject";
?>
php array to string
// for one-dimentional arrays
$str = implode('|', $arr); // "v1|v2|v3"...
// for multi-dimensional/structured arrays, or to keep hierarchy
$str = json_encode($arr);
// or
$str = var_export($arr);
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 "
";
echo"The Json string is $JsonObject";
?>
how to convert array to string in php
/ Declare multi-dimensional array
$value = array(
"name"=>"GFG",
array(
"email"=>"abc@gfg.com",
"mobile"=>"XXXXXXXXXX"
)
);
// Use json_encode() function
$json = json_encode($value);
// Display the output
echo($json);
?>
Convert an Array to a String in PHP
phpCopy<?php
$arr = array("This","is", "an", "array");
$string = implode(" ",$arr);
echo "The array is converted to the string.";
echo "
";
echo "The string is '$string'";
?>
php array to string
$requestAsString = print_r($_REQUEST, true);
Convert an Array to a String in PHP
phpCopyjson_encode( $ArrayName );
Convert an Array to a String in PHP
phpCopyimplode($string, $arrayName);
arry to string php
Convert an Array to a String in PHP
phpCopyserialize($ArrayName);
© 2022 Copyright:
DekGenius.com