Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

json转数组 php

作者:初吻被奶嘴夺走了   发布日期:2024-04-07   浏览:544

您可以使用json_decode()函数将JSON字符串转换为PHP数组。该函数的语法如下:

array json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

下面是一个示例:

$json = '[{"name":"John","age":30,"city":"New York"},{"name":"Jane","age":25,"city":"Los Angeles"}]';
$array = json_decode($json, true);

print_r($array);

输出结果为:

Array
(
    [0] => Array
        (
            [name] => John
            [age] => 30
            [city] => New York
        )

    [1] => Array
        (
            [name] => Jane
            [age] => 25
            [city] => Los Angeles
        )

)

上一篇:php如何把数组成字符串

下一篇:php ftp_rawlist() 函数返回指定目录中文件的详细列表。

大家都在看

php session用法

php 定义常量

phpisset函数

php后端

php爬虫框架

php读取csv文件

php 三元表达式

php文件加密

php 拆分字符串

php pcntl

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站