Jump to content

Recommended Posts

Good day to you all,

            I have a piece of code which read a diredtory and return a list of txt file and display their content.

            I was wondering if there would be a way of making that depending on the time the user load the page, the last created file would appear with their border a different color for 5 stage.

 

example:

if user load the page an hour after a file was created, border colored green...

 

here is my code :

 


function drawList($list)
{  

      $thelist = ''; 
      
      $i = 0;
      foreach($list as $file=>$string)     
      {

$lines = nl2br($string);

    
$usercmt = explode("--", $file);
$messtime = substr($usercmt[1], 0, -4);
$messtimecor = str_replace("-", ":", $messtime);
$usercmtcor = strtoupper($usercmt[0]);

              $thelist .= '<div id="test">';
              $thelist .= "<div id=\"title\"><b>".$usercmtcor."</b> à ".$messtimecor."  (UTC)</div>";  
$lines=explode("\n",$lines);
foreach($lines as $key=>$line)
{  $lines[$key]="<div class=\"contentalt\" style=\"border-top:0; border-left:0; border-right:0; border-bottom:0px  padding:0; \">{$line}</div>";  }
$lines=implode('',$lines);
              $thelist .= "<div id=\"commentbg\">".$lines."</div><br/>";
              $thelist .= '</div><br/><br/>';



}

    return $thelist;

       
}

 

Thanks !

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.