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..
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.
The structure of your resulting array looks something like this mock-up:
If it helps you, here’s what I used to create the array mock-up with the
php -ainteractive interpreter: