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

  • Home
  • SEARCH
  • 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 3224924
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:16:48+00:00 2026-05-17T16:16:48+00:00

I’m wondering how I might go about searching the array below for the key

  • 0

I’m wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too.

For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence?

Thanks in advance, I’ve been searching really hard for the answer and believe i’m over my head!

Output of print_r($updates);

CI_DB_mysql_result Object
(
  [conn_id] => Resource id #30
  [result_id] => Resource id #35
  [result_array] => Array()
  [result_object] => Array()
  [current_row] => 0
  [num_rows] => 5
  [row_data] => 
)

Output of print_r($updates->result_array());

Array
(
  [0] => Array
  (
    [problem_update_id] => 1
    [problem_id] => 3
    [problem_update_date] => 2010-10-01
    [problem_update_text] => Some details about a paricular issue
    [problem_update_active] => 1
  )

  [1] => Array
  (
    [problem_update_id] => 4
    [problem_id] => 3
    [problem_update_date] => 2010-10-01
    [problem_update_text] => Another update about the problem with an ID of 3
    [problem_update_active] => 1
  )

  [2] => Array
  (
    [problem_update_id] => 5
    [problem_id] => 4
    [problem_update_date] => 2010-10-12
    [problem_update_text] => An update about the problem with an ID of four
    [problem_update_active] => 1
  )

  [3] => Array
  (
    [problem_update_id] => 6
    [problem_id] => 4
    [problem_update_date] => 2010-10-12
    [problem_update_text] => An update about the problem with an ID of 6
    [problem_update_active] => 1
  )

  [4] => Array
  (
    [problem_update_id] => 7
    [problem_id] => 3
    [problem_update_date] => 2010-10-12
    [problem_update_text] => Some new update about the problem with the ID of 3
    [problem_update_active] => 1
  )
)
  • 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-05-17T16:16:48+00:00Added an answer on May 17, 2026 at 4:16 pm

    Sorry @maggie. This is almost same as what you wrote, but in function. Hope that will help you. Of course if I understod you correctly.

    function youAskedForIt( $some_array = array(), $value_to_search_for ) {
    
        foreach( $some_array as $value ) {
    
            if( ! isset( $value['problem_id'] ) || ! isset( $value['problem_update_date'] ) || ! isset( $value['problem_update_text'] ) ) {
    
                continue;
    
            }
    
            if( $value_to_search_for == $value['problem_id'] ) {
    
                echo $value['problem_update_date'] . ' => ' . $value['problem_update_text'] . "<br>\n";
    
            }
    
        }
    
    }
    
    youAskedForIt( $updates->result_array(), 3 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.