-2

change the string to array is

$string = '[{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}]';

$array = json_decode($array,true);

but what if it's reversed change array to string

$array = [{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}];

$string = $array; // $string is $string like on first example
2

1 Answer 1

1

You can use json_encode as:

$string = '[{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}]';
$array = json_decode($string,true); // convert string -> array
$string = json_encode($array); // convert array -> string 
echo $string; // will output the original string
Sign up to request clarification or add additional context in comments.

1 Comment

wow thank you so much RIP 6 hours

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.