troubleshooting Question

how to delete matched row of json file using php

Avatar of JohnLourdu
JohnLourduFlag for Afghanistan asked on
Web Languages and StandardsPHP
10 Comments1 Solution1814 ViewsLast Modified:
Hi experts,

I need to delete specific row of json file using php. Below is my code in DelBookLibrary.php:

   $jsonfpath = "epub_content/epub_library.json";
   $input = file_get_contents($jsonfpath);
   $json = json_decode($input,true);
   $match = array('url_to_package_doc'=>'epub_content/moby-dick-20120118/OPS/package.opf', 'title'=>'moby-dick-20120118');
   $upload_info = unset($json['library_epubs'][array_search($match,$json['library_epubs'])]);

my json file epub_library.json is:

{"library_epubs":[{"title":"Page Blanche","url_to_package_doc":"epub_content/page-blanche/EPUB/package.opf","cover_path":"epub_content/page-blanche/EPUB/Image/cover.jpg"},{"title":"Moby Dick","url_to_package_doc":"epub_content/moby_dick/OPS/package.opf","cover_path":"epub_content/moby_dick/OPS/images/9780316000000.jpg"},{"title":"moby-dick-20120118","url_to_package_doc":"epub_content/moby-dick-20120118/OPS/package.opf","cover_path":"epub_content/moby-dick-20120118/OPS/images/9780316000000.jpg"}]}

But I have got below mentioned error:

Parse error: syntax error, unexpected 'unset' (T_UNSET) in /var/www/epubapp/LoginSystem/DelBookLibrary.php on line 40

Please advice.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros