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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:01:50+00:00 2026-05-24T13:01:50+00:00

First of all, I’ve got a result array from a db query that i’m

  • 0

First of all, I’ve got a result array from a db query that i’m spitting out into a html list via a foreach. Secondly I have got a multi-dimensional array with related data in. The relationship is defined in both data sources by “entry_id”.

I want to query the multi-dimensional array on each iteration of the foreach to check if there is a matching entry_id, and if so i want to pull the page title out to add into my html list.
The multi-dimensional array looks like this:

array(4) { 
    [0]=> array(2) { 
            ["entry_id"]=> string(1) "1" 
            ["title"]=> string(4) "Page Title 1" 
        } 
        [1]=> array(2) { 
            ["entry_id"]=> string(1) "2" 
            ["title"]=> string(5) "Page Title 2"
        }
        [2]=> array(2) { 
            ["entry_id"]=> string(1) "3" 
            ["title"]=> string(8) "Page Title 3" 
        } 
        [3]=> array(2) { 
            ["entry_id"]=> string(1) "4" 
            ["title"]=> string(5) "Page Title 4" } 
        }

So firstly, how would you query that multi-dimensional array and get the page title out that you need on that iteration, bearing in mind the sub-arrays have identical keys?

Secondly, what is the most efficient method of doing this, I should also mention that the array could get very large in theory.

  • 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-24T13:01:51+00:00Added an answer on May 24, 2026 at 1:01 pm

    Transform the array so that you have the structure

    entry_id => title
    

    i.e.

    array(
        "1" => "Page Title 1",
        "2" => "Page Title 2"
    )
    

    Then getting the title is just accessing the array with the value of the entry_id.

    If you can, build the array like this from the beginning, if not, you have to iterate over it and create this structure.

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

Sidebar

Related Questions

First of all, I got this huge xml file that represents data collected by
First of all, let me clarify that I know you cannot have actual abstract
First of all I agree that mocking external API calls is the right thing
First of all, as usual, thanks to all for the great support from the
First of all. I want to say that i've acctualy read the other posts
First of all, I am aware that there is a similar topic regarding the
First of all, I know that this is because of bad libraries, but I
First of all, here's my config: VS2010/Debug/C++ Win32 Project/Vista Home Premium Invoking GetOpenFileName via
First of all I have seen that there are many questions about unrecognized selector
First of all, pardon my hacky code, I'm just trying to try this out

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.