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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:24:06+00:00 2026-06-01T05:24:06+00:00

This may be a really dumb question but I’m just starting to learn the

  • 0

This may be a really dumb question but I’m just starting to learn the arrays function. I have this piece of code that works perfectly but only outputs the first value of the array which is [name]. I have a 2nd value in the array which is called [count] that I can’t seem to get to display. What is the correct key to use?

The array output is like this:

[215] => Array ( [name] => Category 1 [count] => 19 )
[263] => Array ( [name] => Category 2 [count] => 12 )

And this is the code:

while ($cat_details = $db->fetch_array($sql_select_categories)) 
{ 
    $cat_array[$cat_details['category_id']]["name"]=$category_lang[$cat_details['category_id']];
    $cat_array[$cat_details['category_id']]["count"]=$cat_details['items_counter'];
}

if(is_array($cat_array)){

asort($cat_array);

    foreach($cat_array as $key => $value ){

        $subcat_link = basename($_SERVER['PHP_SELF']) . '?parent_id=' . $key . $additional_vars;
        $output .= '<tr> '.
        '   <td class="contentfont">&nbsp;&raquo; <a href="' . $subcat_link . '">' . $category_lang[$key] . '</a></td> '.
        '</tr> ';
    }
}

I need to be able to display the $count somewhere in the HTML code of the foreach function. I tried everything from $cat_details[$count] to simply $count but it doesn’t seem to work.

  • 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-01T05:24:07+00:00Added an answer on June 1, 2026 at 5:24 am

    If its inside the foreach you could use $value['count'] to get the value you need

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

Sidebar

Related Questions

This may be a dumb question, but I really have no idea and I'm
This may be a really silly question, but it just crossed my mind and
I feel really dumb for asking this question, but here it goes. I have
I know this may be a stupid question to ask but I have really
This may be a really basic SQL question, but I have seen a SQL
This may be a really dumb question, but... What units does Geography.STLength return? The
I'm just starting out learning C# this may be really simple but in VB
im really new to linq-to-SQL so this may sound like a really dumb question,
This may be a duplicate question, but really don't know how else to word
Ok, this may seem like a stupid question (for Flash Developers) but I really

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.