PHP 将数组转换为 JSON 问题?

Gun*_*tel 2 php arrays json

当我输出print_r($arr)类似的东西时。Array ( [0] => Hello [1] => world);

我尝试使用下面的代码转换为JSON字符串。

$result['result'] = $arr;
json_encode($result);
Run Code Online (Sandbox Code Playgroud)

这会产生以下 JSON 字符串:

{"result" : { "0" : "hello" , "1" : "world"}}
Run Code Online (Sandbox Code Playgroud)

预期结果是这样的:

{ "result" : ["hello" , "world"]}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能获得所需的输出?

RST*_*RST 5

$result['result'] = array_values($arr);
json_encode($result);
Run Code Online (Sandbox Code Playgroud)

仅使用值。