₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,855 members, 8,442,611 topics. Date: Friday, 10 July 2026 at 11:56 AM

Toggle theme

How To Remove A Key From JSON Object In PHP - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersHow To Remove A Key From JSON Object In PHP (1135 Views)

1 Reply

How To Remove A Key From JSON Object In PHP by FincoApps(op): 2:00pm On Aug 13, 2019
When developing with backend technologies like PHP,  a time comes when you need to use and manipulate JSON objects.  One of such manipulations is removing or deleting a JSON key.
There are several ways to do this, however, I find the below method preferable.







unset($json["key"]);




1

unset($json["key"]);





Note that for this method to work, you need to pass a true parameter to the second argument of the json_decode() method.  See the below sample:







$json = json_decode($json , true);
unset($json["key"]);




12

$json = json_decode($json , true);unset($json["key"]);





The second parameter simply tells the method to return an associative array instead of an object.
Hope this helps.
If you have any questions, feel free to ask them in the comment box below. �
... Read more at https://fincoapps.com/how-to-remove-a-key-from-json-object-in-php/
1 Reply

How Do I Fix Update Failed Error Message The Response Is Not A Valid JSON ResponHow To Provide Your Seller Information With Sellers.json On Google AdsenseHow To Remove A Key From JSON Object In PHP234

Easeus Todo Backup 3.4.19 Mac CrackWebsite Development Roadmap For 2023Evaluators Needed To Access My Community Site