How can I get an array such as this:

$array = array(
    "test1" => "blah1",
    "test2" => "blah2",
);

converted to a string like this:

$string = {"test1":"blah1","test2":"blah"}

The array may vary in size so it will have to be dynamic.

Thanks ahead of time.

有帮助吗?

解决方案

This is JSON. Use json_encode().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top