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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:58:47+00:00 2026-06-03T10:58:47+00:00

I wonder how can i find out last in table with PHP, aka if

  • 0

I wonder how can i find out last in table with PHP, aka if that is last then i want to apply different style and content to it.

This is part of my code generating table content.

  $content .= '</tr>';

  $totalcols = count ($columns);
  if (is_array ($tabledata))
  {
    foreach ($tabledata as $tablevalues)
    {
      if ($tablevalues[0] == 'dividingline')
      {
        $content .= '<tr><td colspan="' . $totalcols . '" style="background-color:#efefef;"><div align="left"><b>' . $tablevalues[1] . '</b></div></td></tr>';
        continue;
      }
      else
      {
        $content .= '<tr>';
        foreach ($tablevalues as $tablevalue)
        {
          $content .= '<td>' . $tablevalue . '</td>';
        }

        $content .= '</tr>';
        continue;
      }
    }
  }
  else
  {
    $content .= '<tr><td align="center" style="border-bottom: none;" colspan="' . $totalcols . '">No Records Found</td></tr>';
  }

I know there is option to do something like that with jQuery later on, but I don’t want to complicate it and just solve it with php at time when i generate table.

  • 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-03T10:58:49+00:00Added an answer on June 3, 2026 at 10:58 am

    Keep a count:

    $count = 1;
    foreach ($tablevalues as $tablevalue)
    {
        $count++;
    
        if( $count > count( $tablevalues)) {
            echo "Last td tag is up next! ";
        }
        $content .= '<td>' . $tablevalue . '</td>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I wonder how my code that can be included into different projects can
How can I find out with Android API that a user is trying to
I want to know how to find out if the preprocessor macro __PRETTY_FUNCTION__ can
Out of curiosity, I wonder what can people do with parsers, how they are
How can I accept a command line argument this way: ./a.out --printall so that
Can't find out if daemon application can be run on non-jailbroken iPhone. And what
I wonder how can I export a Visual Studio C++ project to Qt? I
I wonder how can I search for a certain pattern in file, but only
I'd like to start coding for NVIDIA 3D Vision and wonder where can I
wonder whether someone can help me with the following one... I have a struct

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.