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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:22:44+00:00 2026-05-16T16:22:44+00:00

Not sure how to title this, so I apologize if it’s misleading or not

  • 0

Not sure how to title this, so I apologize if it’s misleading or not understandable.
What I have is an array, that array will have 1-4 arrays within it. I need a HTML table to output 4 columns, so even if the array only has one array in it, it still needs to output for columns. The issue I am hitting is that the columns need to match up. Inside of the arrays there is a key called ‘Deductible’ and that key matches up with the HTML table’s columns. The Array, PHP, current HTML output and wanted HTML output are all below and a link to PasteBin in case this post doesn’t display it all correctly.

// OUTPUT OF $estimateOutput

array (
  0 => 
  array (
    'AdminCode' => 'NASC',
    'AdminName' => 
    array (
    ),
    'NewUsed' => 'Used',
    'CoverageCode' => 'NCGUGOLD',
    'CoverageName' => 'GOLD USED COMPONENT 1-10',
    'GenericCoverage' => 
    array (
    ),
    'Term' => '24/24',
    'TermInMonths' => '24',
    'TermInMilesKM' => '24000',
    'Deductible' => '100',
    'RetailCost' => '1377.0',
  ),
  1 => 
  array (
    'AdminCode' => 'NASC',
    'AdminName' => 
    array (
    ),
    'NewUsed' => 'Used',
    'CoverageCode' => 'NCGUGOLD',
    'CoverageName' => 'GOLD USED COMPONENT 1-10',
    'GenericCoverage' => 
    array (
    ),
    'Term' => '24/24',
    'TermInMonths' => '24',
    'TermInMilesKM' => '24000',
    'Deductible' => '50',
    'RetailCost' => '1462.0',
  ),
)


$estimateOutput .= '<tr class="month-section"><td colspan="5"><strong>'.$term_length.' Months</strong></td></tr>';
if($rateEstimate != ""){
  foreach($rateEstimate as $rate) {
    $ratesByMiles[$rate["TermInMilesKM"]][] = $rate;
  }
  foreach($rateEstimate as $key=>$value){
    if($TermInMilesKM != $value['TermInMilesKM']){
      $estimateOutput .= '<tr>';
      $estimateOutput .= '<td>'.number_format($value['TermInMilesKM']).'</td>';

      foreach($ratesByMiles[$value['TermInMilesKM']] as $newval){
        $estimateOutput .= '<td>';
        $estimateOutput .= '<a href="#" rel="'.$newval['CoverageCode'].'::'.$newval['Term'].'::'.$newval['Deductible'].'::'.$newval['RetailCost'].'">$';
        $estimateOutput .= number_format($newval['RetailCost']);
        $estimateOutput .= '</a>';
        $estimateOutput .= '</td>';
      }
      $estimateOutput .= '</tr>';
      $TermInMilesKM = $value['TermInMilesKM'];
    }
  }
} else {
  $estimateOutput .= '<tr><td colspan="5">Not Available</td></tr>';
}
echo $estimateOutput;



// CURRENTLY OUTPUTTING
<tr class="month-section" style="display: table-row;">
  <td colspan="5"><strong>24 Months</strong></td>
</tr>
<tr style="display: table-row;">
  <td>24,000</td>
  <td><a rel="NCGUGOLD::24/24::50::1462.0" href="#">$1,462</a></td>
  <td><a rel="NCGUGOLD::24/24::100::1377.0" href="#">$1,377</a></td>
</tr>



// NEED IT TO OUTPUT

<tr class="month-section" style="display: table-row;">
  <td colspan="5"><strong>24 Months</strong></td>
</tr>
<tr style="display: table-row;">
  <td>24,000</td>
  <td>--</td> // If $newval['Deductible'] == 0 this should show data, otherwise --
  <td><a rel="NCGUGOLD::24/24::50::1462.0" href="#">$1,462</a></td> // If $newval['Deductible'] == 50 this should show data, otherwise --
  <td><a rel="NCGUGOLD::24/24::100::1377.0" href="#">$1,377</a></td> // If $newval['Deductible'] == 100 this should show data, otherwise --
  <td>--</td> // If $newval['Deductible'] == 200 this should show data, otherwise --
</tr>

http://pastebin.com/y41MA8VZ

  • 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-16T16:22:45+00:00Added an answer on May 16, 2026 at 4:22 pm

    Always loop four times, then find the correct array to print:

    $deductable_values = array(0, 50, 100, 200);
    foreach ($deductable_values as $deductable_value) {
        $data = find_deductible_array($estimateOutput, $deductable_value);
        // output a row using $data, which may be null.
    }
    
    function find_deductible_array($estimateOutput, $value) {
        foreach ($estimateOutput as $row) {
            if ($row['deductible'] == $value) {
                return $row;
            }
         }
         // not found
         return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Not sure if this title is the best description...) Hi all. I need a
(not sure if title explains the matter well enough) I have this piece of
I'm not really sure how to title this question but basically I have an
My apologies for an inaccurate title, but I'm not sure what this is called
Not entirely sure of a good title for this, feel free to edit it
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
for sure this is not the best title. I'm creating a system to generate
I'm not sure that title is worded very well, but not sure how else
I'm not sure that title conveys my meaning, please change it if you can
I am not sure my title is correct or not since I have no

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.