将Php数组编码为json [英] encode Php array to json
本文介绍了将Php数组编码为json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对我的php数组进行编码
I want to encode my php array
Array (
[0] => Laravel,
[1] => hallo
)
变成如下所示的json
数组
{"val":["Laravel","hallo"]}
有人知道我该怎么做吗?
anybody have an idea how i do this?
推荐答案
尝试一下:
$array = array("val"=>$your_array);
$json_str = json_encode($array);
参考: http://php.net/manual/en/function. json-encode.php
这篇关于将Php数组编码为json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文