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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:16:31+00:00 2026-06-14T22:16:31+00:00

im having a array which contains user data with a classification. im try to

  • 0

im having a array which contains user data with a classification. im try to output the total_sum at the end of the last classification group throught the end of the array

array(22) {
  [0]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "4334"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(20) "tregfdgfd"
    ["classifi"]=>
    string(2) "1A"
    ["total_sum"]=>
    string(5) "45000"
  }
  [1]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "4336"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(19) "ewrtgfgdfg"
    ["classifi"]=>
    string(2) "1A"
    ["total_sum"]=>
    string(5) "45000"
  }
  [2]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "4340"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(16) "ihjkhjbmgy"
    ["classifi"]=>
    string(2) "1A"
    ["total_sum"]=>
    string(5) "45000"
  }
  [3]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "4394"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(20) "ertgfbfjghj"
    ["classifi"]=>
    string(2) "1B"
    ["total_sum"]=>
    string(5) "30000"
  }
  [4]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "4396"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(21) "dwerdsfdf"
    ["classifi"]=>
    string(2) "1B"
    ["total_sum"]=>
    string(5) "30000"
  }
  [5]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "3496"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(23) "rergfdg"
    ["classifi"]=>
    string(2) "3A"
    ["total_sum"]=>
    string(5) "35000"
  }
  [6]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "3796"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(19) "ghjyuytuyt"
    ["classifi"]=>
    string(2) "3A"
    ["total_sum"]=>
    string(5) "35000"
  }
  [7]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "3797"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(25) "qeevvf"
    ["classifi"]=>
    string(2) "3B"
    ["total_sum"]=>
    string(5) "35000"
  }
  [8]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "3827"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(17) "qvfrrere"
    ["classifi"]=>
    string(2) "3B"
    ["total_sum"]=>
    string(5) "35000"
  }
  [9]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "1921"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(28) "ewrewrsdf"
    ["classifi"]=>
    string(2) "6A"
    ["total_sum"]=>
    string(5) "37000"
  }
  [10]=>
  array(5) {
    ["reg_numb"]=>
    string(4) "2324"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(23) "abcdddsf"
    ["classifi"]=>
    string(2) "6A"
    ["total_sum"]=>
    string(5) "37000"
  }
  [11]=>
  array(5) {
    ["months"]=>
    string(2) "10"
    ["reg_numb"]=>
    string(4) "1922"
    ["month"]=>
    string(10) "2012-01-01"
    ["name"]=>
    string(22) "test123"
    ["classifi"]=>
    string(2) "6B"
    ["total_sum"]=>
    string(5) "37000"
  }

foreach:

  <?php  foreach ($infos as $info):?>
 <tr>
      <td colspan = "2"><?php echo $info['reg_numb']?></td>
        <td><?php echo $info['name']?></td>
        <td><?php echo $info['classifi']?></td>
        <td style="text-align: center"><?php echo $info['months']?>Months</td>

    if its the last row in a classfi grpup out put the below row with total for that classifi
    <tr>
      <td colspan = "3">Total</td>
      <td style="text-align: right"><hr /><?php echo $info[total_sum]?> </td>
    </tr>

    begin the next classifi group
    <?php endforeach;?>

so i will get a table with the list of user data and the total and then the other group of users.

any help on how to achieve this?

  • 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-14T22:16:32+00:00Added an answer on June 14, 2026 at 10:16 pm

    Try as below

    <?php
       $new_data = array();
       foreach ($infos as $key => $info):
          $new_data[$info['classifi']][] = $info;
       endforeach;
    ?>
    
    <?php foreach ($new_data as $key1 => $arrinfo):?>
    <?php  foreach ($arrinfo as $key => $info):?>
     <tr>
          <td colspan = "2"><?php echo $info['reg_numb']?></td>
            <td><?php echo $info['name']?></td>
            <td><?php echo $info['classifi']?></td>
            <td style="text-align: center"><?php echo $info['months']?>Months</td>
    
    //    if its the last row in a classfi grpup out put the below row with total for that classifi
    
       // Check everytimg is it last record
       <?php if($key==count($arrinfo)-1) {?>
        <tr>
          <td colspan = "3">Total</td>
          <td style="text-align: right"><hr /><?php echo $info[total_sum]?> </td>
        </tr>
       <?php } ?>   
       // begin the next classifi group
    <?php  endforeach;?>
    <?php endforeach;?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an empty json object having an array itemlist(which further contains itemid
I am having an array $IPAddress which contains IPv4 and IPv6 address like below.
I have variable call items having array of items which contains following value [[#<Item
I'm having some trouble manipulating a complex array which looks like this: Array (
I'm currently having an issue storing mouse coordinates into an array in which a
I am having an array that contains different urls, and a set of buttons,
I have an (access) database table which contains data I would like to populate
I'm having an array of data in PHP. It is a lot of data
I m new to Jquery. I'm having hidden variable which contains all span tag
So I have a backend implementation in node.js which mainly contains a global 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.