如何在PHP中将json转换为arry

问题描述 投票:-1回答:1

嗨,我需要垂涎

this(json)

["theory",["theory","theory of relativity","theory test","theory of everything","theory definition","theory of evolution","theory of mind","theory of a deadman","theory of love","theory meaning"]]

到(数组php)

array (
  0 => 'theory',
  1 => 
  array (
    0 => 'theory',
    1 => 'theory of relativity',
    2 => 'theory test',
    3 => 'theory of everything',
    4 => 'theory definition',
    5 => 'theory of evolution',
    6 => 'theory of mind',
    7 => 'theory of a deadman',
    8 => 'theory of love',
    9 => 'theory meaning',
  ),
)

我需要将json转换为数组php

如何获得“相对论”?

php json var-dump
1个回答
0
投票

您应使用https://www.php.net/manual/en/function.json-decode.php

示例:

$myJson = '["theory",["theory","theory of relativity","theory test","theory of everything","theory definition","theory of evolution","theory of mind","theory of a deadman","theory of love","theory meaning"]]';

print_r(json_decode($myJson));
© www.soinside.com 2019 - 2024. All rights reserved.