English 中文(简体)
如何通过一名JSON进行搜查?
原标题:How to search through a JSON?

I m 试图通过使用PHP的Json阵列搜索:

{"count":"2","items":{"milestone":[{"id":"3107","username":"TomSmith1","userid":"1620602","date":"2012-01-12 16:49:26","projectid":"804","projectname":"TEST PROJECT","reason":"Partial payment for project","amount":"25","currency":"1"},{"id":"3111","username":"HarryCole","userid":"1620603","date":"2012-01-13 16:42:39","projectid":"804","projectname":"TEST PROJECT 2","reason":"Partial payment for project","amount":"10","currency":"1"}]}}

我想通过这一方法寻找“id”,该项目的名称是“TEST PROJECT 2”和用户名称“HarryCole”。 我曾尝试使用<代码>foreach loop,但n t继承。 谁能向我指出正确的方向? 感谢。

最佳回答

页: 1 https://www.php.net/json_decode。 并且还有一种像 for一样的 for

foreach($json_decoded as $key=>$value) {
     // Check for id / values
}
问题回答

请使用<代码>json_decode($json, real),说明如何将其从JSON改为PHP(联系阵列)。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签