相关疑难解决方法(0)

JSON搜索并在PHP中删除?

我有一个$_SESSION["animals"]包含深度json对象的会话变量,其值为:

$_SESSION["animals"]='{
"0":{"kind":"mammal","name":"Pussy the Cat","weight":"12kg","age":"5"},
"1":{"kind":"mammal","name":"Roxy the Dog","weight":"25kg","age":"8"},
"2":{"kind":"fish","name":"Piranha the Fish","weight":"1kg","age":"1"},
"3":{"kind":"bird","name":"Einstein the Parrot","weight":"0.5kg","age":"4"}
}'; 
Run Code Online (Sandbox Code Playgroud)

例如,我想找到"Piranha the Fish"的行,然后将其删除(并将json_encode重新编码).这该怎么做?我想我需要在json_decode($_SESSION["animals"],true)结果数组中搜索并找到要移除的父键但是我仍然被卡住了.

php json

6
推荐指数
1
解决办法
1万
查看次数

使用php从json中删除

我当前的json代码:

{"Results":[{"username":"test","password":"test"},{"username":"test","password":"test"},{"username":"google","password":"test"},{"username":"yahoo","password":"test"},{"username":"hotmail","password":"test"}]}
Run Code Online (Sandbox Code Playgroud)

我想删除这个:

{"username":"google","password":"test"}
Run Code Online (Sandbox Code Playgroud)

从使用PHP的代码.我尝试通过解码json到数组来删除但不能完成它.任何解决方案

php json

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

json ×2

php ×2