Answered by : abs-zarzis
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated;
// lastname,email,phone
?>
Source : https://www.php.net/manual/en/function.implode.php | Last Update : Wed, 01 Dec 21
Answered by : pawan-mall
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";
?>
Source : https://www.delftstack.com/howto/php/how-to-convert-an-array-to-a-string-in-php/ | Last Update : Fri, 30 Apr 21
Answered by : pawan-mall
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";
?>
Source : https://www.delftstack.com/howto/php/how-to-convert-an-array-to-a-string-in-php/ | Last Update : Fri, 30 Apr 21
Answered by : niki-romagnoli
// 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);
Source : | Last Update : Wed, 24 Feb 21
Answered by : jose-guerrero
$integerIDs = array_map('intval', explode(',', $string));
Source : https://stackoverflow.com/questions/9593765/how-to-convert-array-values-from-string-to-int | Last Update : Tue, 22 Sep 20
Answered by : famous-flatworm-jobjpt34hokw
/ Declare multi-dimensional array
$value = array( "name"=>"GFG", array( "email"=>"[email protected]", "mobile"=>"XXXXXXXXXX" )
);
// Use json_encode() function
$json = json_encode($value);
// Display the output
echo($json);
?>
Source : | Last Update : Tue, 12 Jul 22
Answered by : pawan-mall
phpCopy<?php
$arr = array("This","is", "an", "array");
$string = implode(" ",$arr);
echo "The array is converted to the string.";
echo "\n";
echo "The string is '$string'";
?>
Source : https://www.delftstack.com/howto/php/how-to-convert-an-array-to-a-string-in-php/ | Last Update : Fri, 30 Apr 21
Answered by : magsverge-solutions
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated;
//OR
$array = array('lastname', 'email', 'phone');
$comma_separated = join(",", $array);
echo $comma_separated;
// lastname,email,phone
/* The implode() method is an inbuilt function in PHP and is used to join the elements of an array. The implode() method is an alias for PHP | join() function and works exactly same as that of join() function.
*/
?>
Source : | Last Update : Wed, 15 Jun 22
Answered by : poor-panda-apimkeam0vgw
echo json_encode($person);
Source : | Last Update : Wed, 17 Nov 21
Answered by : -1vajs8k9qntw
$requestAsString = print_r($_REQUEST, true);
Source : | Last Update : Wed, 29 Sep 21