Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,190,517 members, 7,940,963 topics. Date: Thursday, 05 September 2024 at 02:30 PM

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

Nairaland Forum / Science/Technology / Webmasters / How To Remove A Key From JSON Object In PHP (726 Views)

How To Provide Your Seller Information With Sellers.json On Google Adsense / How To Remove A Key From JSON Object In PHP / Professional Html,bootstrap,php,java,json Web Deloper. Pay After Service! (2) (3) (4)

(1) (Reply)

How To Remove A Key From JSON Object In PHP by FincoApps(m): 1:59pm On Aug 31, 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 To Manage Payments And Shipping In Opencart / Please Help! My Phpbb Forum Is Down / Business Plan Writers Needed

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 7
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.