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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:56:37+00:00 2026-06-18T10:56:37+00:00

I have an multidimensional array like this: Array ( [Category1] => Array ( [1]

  • 0

I have an multidimensional array like this:

Array
(
    [Category1] => Array
        (
            [1] => Array
                (
                    [0] => Img 1
                    [1] => Title 1
                    [2] => Text 1
                )

            [5] => Array
                (
                    [0] => Img 17
                    [1] => Title 17
                    [2] => Text 5
                )

            [10] => Array
                (
                    [0] => Img 1
                    [1] => Title 6
                    [2] => Text 10
                )

            [16] => Array
                (
                    [0] => Img 16
                    [1] => Title 12
                    [2] => Text 16
                )

        )

    [Category2] => Array
        (
            [2] => Array
                (
                    [0] => Img 2
                    [1] => Title 2
                    [2] => Text 2
                )

            [6] => Array
                (
                    [0] => Img 18
                    [1] => Title 18
                    [2] => Text 6
                )

            [13] => Array
                (
                    [0] => Img 13
                    [1] => Title 9
                    [2] => Text 13
                )

        )

    [Category3] => Array
        (
            [3] => Array
                (
                    [0] => Img 3
                    [1] => Title 3
                    [2] => Text 3
                )

            [7] => Array
                (
                    [0] => Img 19
                    [1] => Title 19
                    [2] => Text 7
                )

            [11] => Array
                (
                    [0] => Img 11
                    [1] => Title 7
                    [2] => Text 11
                )

            [14] => Array
                (
                    [0] => Img 14
                    [1] => Title 10
                    [2] => Text 14
                )

        )

    [Category4] => Array
        (
            [4] => Array
                (
                    [0] => Img 4
                    [1] => Title 4
                    [2] => Text 4
                )

            [8] => Array
                (
                    [0] => Img 20
                    [1] => Title 20
                    [2] => Text 8
                )

            [15] => Array
                (
                    [0] => Img 15
                    [1] => Title 11
                    [2] => Text 15
                )

        )

    [Category5] => Array
        (
            [9] => Array
                (
                    [0] => Img 9
                    [1] => Title 5
                    [2] => Text 9
                )

        )

    [Category6] => Array
        (
            [12] => Array
                (
                    [0] => Img 12
                    [1] => Title 8
                    [2] => Text 12
                )

        )

)

I need help to view like this, there $myarray is as on top example.
In the firs foreach all it’s OK but in the sencond and the third foreach if i have more then one array at one category it is dublicated and displayed not corectly.

<div id="tab-container">
        <ul>
            <?php foreach ($myarray as $category => $detail) { ?>
                <li><a href="#tab-<?=$category?>"><?=$category?></a></li>
            <?php }; ?>
        </ul>

    <div>
        <?php foreach (??? ??? ???) { ?>
            <div id="tab-<?=$category?> for ex Category 1 contain Array (1, 5 10, 16)">
                <div class="tab-content_left">
                    <div><img src="<?=base_url();?>img/$value[0] for ex Img 1" /></div>
                    <div>$value[1] for ex Title 1</div>
                    <div>$value[2] for ex Text 1</div>
                </div>

                <div class="tab-content_right">
                    <?php foreach (??? ??? ???) { ?>
                        <div><img src="<?=base_url();?>img/"$value[0] for ex Img 17 /></div>
                        <div>$value[1] for ex. Title 17</div>
                        <div>$value[2] for ex Text 5</div>
                    <?php }; ?>
                </div>
            </div>
        <?php }; ?>
    </div>
</div>

THX. Please some ideas how can i put foreach cicles and where?

  • 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-18T10:56:38+00:00Added an answer on June 18, 2026 at 10:56 am

    First foreach:

    <?php foreach ($mainArray as $categoryKey => $singleCategory) { ?>
    

    Second foreach:

    <?php foreach ($singleCategory as $categoryEntry) { ?>
    

    Note:

    To get the category name write $categoryKey in the first foreach.
    To get data write: $singleCategory['image'] inside the second foreach.

    Check foreach documentation.

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

Sidebar

Related Questions

I have an multidimensional array that looks like this: Array ( [0] => Array
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have a multidimensional array like this: [ 'user 1' => [ ['item 4'
I have created a multidimensional dynamic array like this int N; cin >> N;
I have a multidimensional array like this: Array ( [0] => Array ( [ans_id]
I have a multidimensional array like this: array(2) { [1]=> array(3) { [eventID]=> string(1)
I have a multidimensional array like this $array['value'][1][1] Now i would like to implement
I have a multidimensional array that looks like this [0] => Array ( [recordId]
I have a multidimensional array which looks like this: Array ( [0] => Array
I have a multidimensional array that when i use print_r looks like this: Array

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.