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 8277115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:35:42+00:00 2026-06-08T08:35:42+00:00

Here is print_r output of my array: Array ( [0] => stdClass Object (

  • 0

Here is print_r output of my array:

Array
(
[0] => stdClass Object
    (
        [itemId] => 560639000019
        [name] => Item no1
        [code] => 00001
        [qty] => 5
        [id] => 2
    )

[1] => stdClass Object
    (
        [itemId] => 470639763471
        [name] => Second item
        [code] => 76347
        [qty] => 9
        [id] => 4
    )

[2] => stdClass Object
    (
        [itemId] => 56939399632
        [name] => Item no 3
        [code] => 39963
        [qty] => 6
        [id] => 7
    )

)

How can I find index of object with [id] => 4 in order to remove it from array?

  • 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-08T08:35:44+00:00Added an answer on June 8, 2026 at 8:35 am
    $found = false;  
    foreach($values as $key => $value) {
        if ($value->id == 4) {
            $found = true;
            break;
        }
    }
    
    if ($found) unset($values[$key]);
    

    This is considered to be faster then any other solution since we only iterate the array to until we find the object we want to remove.

    Note: You should not remove an element of an array while iterating so we do it afterwards here.

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

Sidebar

Related Questions

print_r($address['Country']); echo $address['Country']['name']; Here is what I get for the print_r: Array ( [Country]
Ok, so here's my code: $output = array(); $output['num_items_in_tree'] = 0; $output['date_of_most_recent_item'] = $today;
In following php code in here //print_r($reunits); is output this: http://pastebin.com/RbqZ5kHV but in here
I have an array like this (output from print_r ): Array ( [price] =>
WP outputs an array: $therapie = get_post_meta($post->ID, 'Therapieen', false); print_r($therapie); //the output of print_r
This has got me completely stumped: print_r($json); echo json_encode($json); output: Array ( [query] =>
Here in my code: <?php $urls = array('http://www.website1.com/image1.jpg', 'http://www.website2.com/image/image2.jpg', 'http://www.website3.com/image/url/image3.jpg' ); while(list($i, $uri) =
Here is the code: $obj = new stdClass; $obj->AAA = aaa; $obj->BBB = bbb;
class HelloWorld(object): def say_it(self): return 'Hello I am Hello World' def i_call_hello_world(hw_obj): print 'here...
Here's my code that is not working: print To: ; my $to=<>; chomp $to;

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.