<?php

// in real code we'd read from a file
// $lines = file('./cookie.txt');

/**
 * we assume this is in our file
 **/
$f = "
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
 
.google.com	TRUE	/	FALSE	1305843382	cookiename	the value
.yahoo.com	TRUE	/	FALSE	1305843382	another_cookie	it's value

";

$lines = explode(PHP_EOL, $f);
$trows = '';
// iterate over lines
foreach($lines as $line) {
  
  // we only care for non-comment, non-blank lines
  if($line[0] != '#' && substr_count($line, "\t") == 6) {
    // get tokens in an array
    $tokens = explode("\t", $line);

    // trim the tokens
    $tokens = array_map('trim', $tokens);

    // let's convert the expiration to something readable
    $tokens[4] = date('Y-m-d h:i:s', $tokens[4]);

    // we can do different things with the tokens, here we build a table row
    $trows .= '<tr><td>' . implode('</td><td>', $tokens) . '</td></tr>' . PHP_EOL;

  }

}

// complete table and send output
echo "
<table>
<tbody>
$trows</tbody>
</table>";

?>
