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

json字符串转为json数组 php

作者:昔日暖阳   发布日期:2024-04-15   浏览:712

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

json_decode($json_string, true);

其中,$json_string是要转换的JSON字符串,true参数表示将JSON对象转换为关联数组。

以下是一个示例:

$json_string = '[{"name":"John", "age":30, "city":"New York"}, {"name":"Jane", "age":25, "city":"Los Angeles"}]';

$json_array = json_decode($json_string, true);

print_r($json_array);

输出结果为:

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

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

)

上一篇:如何数组化操作对象php

下一篇:php数组求和函数怎么算

大家都在看

php session用法

php 定义常量

phpisset函数

php后端

php爬虫框架

php读取csv文件

php 三元表达式

php文件加密

php 拆分字符串

php pcntl

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

Laravel 中文站