Check out my twitter script by CMXads
Evil gear Christmas is almost here | Goth and Gore Gifts Shop right now or else! | Till death do us part Axels New Music releases | Viking gear Gear Gifts and Apparel |
here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.
delete file entry based on a time comparison
delte time compare
<?php
$output = array();
// Read the file into an array of lines:
$lines = file('yourfile.txt');
// Store the current time
$now = time();
foreach ($lines as $line) {
// Split on |
list($content, $time) = explode("|", $line);
if ($time > $now) {
// Keep the line in the output array:
$output[] = $line;
}
// Otherwise do nothing with it
}
// Implode it back to a string and write to file:
$outstring = implode("\n", $output);
file_put_contents("yourfile.txt", $outstring);
delete by time
$input = fopen("file.txt", "rb");
$output = fopen("output.txt", "wb");
$now = time();
while ($row = fgets($input))
{
list($content, $time) = explode("|", $row);
if ($time > $now)
{
// change to echo to write to stdout
fwrite($output, $row);
}
}
fclose($input);
fclose($output);
?>