You are here: Q: how can i cache data that took from a txt file before? « All PHP « IT news, forums, messages
Q: how can i cache data that took from a txt file before?

Posted by onurpay on 03/03/07 11:16

Hi there. i need to cache data from a txt file.
problem : the txt file is too big. it has lots of categories in it. it
is too slow to show that data in my page. so i want to cache it maybe
in a txt or xml file in my server. so second time that i need the data
it won't be too slow. i want to take the data once in a day but show
several times. the code below is working as well as i need. but it is
too slow to open every time refresh my page. if any suggestions, thank
you.
Güncel : is a category name in the txt file.
BCList2.txt : data file from another site

here is the code

<?
if (!$kategori_haber) $kategori_haber = array("Guncel");
$satir = file("http://www.ntvmsnbc.com/news/BCList2.txt") or die("news
server is off!");
for ($x = 0; $x < sizeof($kategori_haber); $x++) {
for ($i = 0; $i < sizeof($satir); $i++) {
if (trim($satir[$i]) == "+$kategori_haber[$x]") {
$bas = $i + 2;
break;
}
}
for ($i = $bas; $i < sizeof($satir); $i++) {
if (substr($satir[$i], 0, 1) == "+" || $i == sizeof($satir) - 1) {
$son = $i;
break;
}
}
for ($i = $bas; $i < $son; $i++) {
$yazi = trim($satir[$i]);
if ($yazi != "-" && !eregi("$kategori_haber[$x] Guncel", $yazi)) {
$yazi = str_replace("/news/./", "http://www.ntvmsnbc.com/news/",
$yazi);
$haber_e = explode("|", $yazi);
$haber_e[0]=str_replace("http://www.ntvmsnbc.com/news/", "",
$haber_e[0]);
echo "·<font face=verdana size=1>&nbsp;<a href=\"http://
www.ntvmsnbc.com/news/$haber_e[0]\" target=_blank >$haber_e[1]</a></
font></br>\n";
}
}
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация