dpthuyh1678 2016-03-10 02:32
浏览 47
已采纳

如何将JSON字符串更改为单个数组

I have a json string, now i want it to become another string like an array and the $key is the same with $value

original string:

$input='
{
        "label_values":[
        "OK1","OK2","OK3"
        ]
}'

tried json_decode

$obj = json_decode($input);
$results = $obj->{'label_values'};
$result = implode(",", $results);

and $result export OK1,OK2,OK3

$key is the same with $value,i want it change to below example

Array(
        "OK1"=>"OK1",
        "OK2"=>"OK2",
        "OK3"=>"OK3"
)

Any help is greatly appreciated

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 这段有什么bug 为什么总报错
      • ¥15 关于#php#根据url判断选择加载模板应该如何解决?会的速来捡钱!
      • ¥15 Intel Realsense深度相机(D415/D435)拍摄梯子获取梯子点云
      • ¥50 unity使用easyar录屏更换视频保存路径
      • ¥15 CECGameSession::OutputLinkSevError(iRetCode=4) LINK超时
      • ¥20 出错 textread (第 124 行) [varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
      • ¥15 tensor flow目标检测环境配置问题
      • ¥15 数据库float型转换精度问题
      • ¥15 运行您代码时出现报错,如何解决?(标签-回归|关键词-无法识别)
      • ¥50 android service弹出dialog,showdialog就出错,如何解决?