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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:52:42+00:00 2026-05-23T14:52:42+00:00

I’m building a program that parses a website and store links and images, i’m

  • 0

I’m building a program that parses a website and store links and images, i’m storing them in separate arrays, one array for the links, one for images, etc.. I want it to save on one multidimensional array.. how can I do it ? I have three functions that return an ID array, containing ID’s from the topic i’m storing, another function that returns an array of titles from the topics i’m saving and another function that return an array with all image links.. so my “main” function is:

$array_id = getIds();
$array_titles = getTitles($array_id);
$array_images = getImages($array_id);

I want to store it in somewhay that when I call like:

$array[$id][$images]

I get all images on this topic ID, or if I call

$array[$id][$title]

I get the title on this topic ID, is this possible ? or is this the best way to do it ? I’m new to php, i would make a struct if I were using C, so I don’t know if there is anything equivalent to it on php, thank you very much..

  • 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-23T14:52:42+00:00Added an answer on May 23, 2026 at 2:52 pm

    Rather than functions returning arrays of all titles and all images, you will need functions that return only the titles or images related to a single id. We don’t see how you’re defining your functions.

    //Get all your ids
    $array_id = getIds();
    
    // Functions take an id and retrieve only its related objects
    function getTitles($id) {}
    function getImages($id) {}
    
    //Iterate over the ids,  and retrieve the titles and images for each
    foreach ($array_id as $id)
    {
      // getTitles returns an array, keyed as 'titles' in the id array
      $id['titles'] = getTitles($id);
    
      // getImages returns an array, keyed as 'images' in the id array
      $id['images'] = getImages($id);
    }
    
    // Now you can retrieve them like so:
    // A single title...
    echo $array_id[0]['titles'][0];
    // All titles
    print_r($array_id[0]['titles'];
    

    The structure of your resulting array looks something like this mock-up:

    Array
    (
        [0] => Array
            (
                [titles] => Array
                    (
                        [0] => title 0a
                        [1] => title 0b
                        [2] => title 0c
                    )    
                [images] => Array
                    (
                        [0] => img0a.jpg
                        [1] => img0b.jpg
                    )    
            )    
        [1] => Array
            (
                [titles] => Array
                    (
                        [0] => title 1a
                        [1] => title 1b
                        [2] => title 1c
                    )    
                [images] => Array
                    (
                        [0] => img1a.jpg
                        [1] => img1b.jpg
                    )    
            )    
        [2] => Array
            (
                [titles] => Array
                    (
                        [0] => title 2a
                        [1] => title 2b
                        [2] => title 2c
                    )    
                [images] => Array
                    (
                        [0] => img2a.jpg
                        [1] => img2b.jpg
                    )    
            )    
    )
    

    If it helps you, here’s what I used to create the array mock-up with the php -a interactive interpreter:

    php > $ids = array();
    php > $ids[0] = array('titles'=>array('title 1', 'title 2', 'title 3'), 'images'=>array('img1.jpg', 'img2.jpg'));
    php > $ids[1] = array('titles'=>array('title 1a', 'title 1b', 'title 1c'), 'images'=>array('img1a.jpg', 'img1b.jpg'));
    php > $ids[2] = array('titles'=>array('title 2a', 'title 2b', 'title 2c'), 'images'=>array('img2a.jpg', 'img2b.jpg'));
    php > $ids[0] = array('titles'=>array('title 0a', 'title 0b', 'title 0c'), 'images'=>array('img0a.jpg', 'img0b.jpg'));
    php > print_r($ids);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.