Home>Article>Backend Development> How to convert json object to array in thinkphp5 (code)

How to convert json object to array in thinkphp5 (code)

不言
不言 Original
2018-08-04 11:39:55 11628browse

The content of this article is about how to convert json objects into arrays (code) in thinkphp5. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Initially we use the following code to output:

The above code will output the following json object:

.

If we want to output on the page, we must convert it into an array:

$list = json_decode($list->getContent(),true); $this->assign('data',$list['data']); return $this->fetch('tea');

In this way, we can convert the json object into an array, and take out the data array in $list, and then We use the volist tag to loop the output in the front desk:

{volist name="data" id="it"}  

教师:{$it.teachername}

任课:{$it.course}

{/volist}

In this way, our front desk page comes out:

Recommended related articles:

How to check whether a remote file exists in php (pure code)

Code example of how to delete a directory and all files in the directory

The above is the detailed content of How to convert json object to array in thinkphp5 (code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn