Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:10:05+00:00 2026-06-07T07:10:05+00:00

Basically the json output is this -output is from php. [{attr:{id:node_2,rel:default},data:C:,state:closed},{attr:{id:node_3,rel:drive},data:D:,state:closed}] so because rel

  • 0

Basically the json output is this -output is from php.

[{"attr":{"id":"node_2","rel":"default"},"data":"C:","state":"closed"},{"attr":{"id":"node_3","rel":"drive"},"data":"D:","state":"closed"}]

so because rel is equal to default

{"attr":{"id":"node_2","rel":"default"},"data":"C:","state":"closed"}

I need to remove this from the array.

I have thought of maybe using

foreach($arr as $key => &$item) {
    if ($value['rel'] == 'default'{
        unset($arr[$key]);

This however, wont work for some reason. I have no idea if my method is the best way, or whether there is a better way to achieve this.
I also need to decode and encode it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:10:07+00:00Added an answer on June 7, 2026 at 7:10 am

    You can use json_encode and json_decode to parse the json as Jesse Bunch said.

    After i decoded the json you posted, it returned as an object. To call on an object you have to do things a bit diffrent.

    $arr = json_decode('[{"attr":{"id":"node_2","rel":"default"},"data":"C:","state":"closed"},{"attr":{"id":"node_3","rel":"drive"},"data":"D:","state":"closed"}]');
    
    foreach($arr as $key => $row)
    {
        if ($row->attr->rel == 'default'){
            unset($arr[$key]);
        }
    }
    
    var_dump($arr);
    

    The $arr does no longer contain the default rel

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically idea is to grab data from MySQL table and transform it to JSON.
Basically, I have a JSON response from the Twitter API containing a timeline. I
I'm trying to parse the json grabbed from here . Basically what I do
Basically I have a php script located on a sever that generates a JSON
This is basically a theoretical question on the way the decoding of a JSON
http://pastebin.com/FE2i1sqV - this is the json data file... This is the code I use
Just wondering which is best here. I want to output data from a table
I ran into a problem with jqGrid and JSON data. Basically the grid will
I'm writing an API for retrieving data from a JDBC-connected Java Servlet via JSON.
I am having trouble on formatting my json. Basically I have this script structure,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.