|
Posted by Jeff North on 03/03/07 11:30
On 3 Mar 2007 03:07:39 -0800, in comp.lang.php onurpay@gmail.com
<1172920059.835954.229200@8g2000cwh.googlegroups.com> wrote:
>|
>| Güncel : is a category name in the txt file.
>| BCList2.txt : data file from another site
>| problem : the txt file is too big. it has lots of categories in it. i
>| need only "Güncel" category. also it is too slow to show that category
>| in my page. so i want to cache it maybe in a txt 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.
>|
>| here is the code
>|
>| <?
>| if (!$kategori_haber) $kategori_haber = array("Güncel");
>| $satir = file("http://www.ntvmsnbc.com/news/BCList2.txt") or
>| die("Serverla ileti?im sa?lanamad?!");
>| 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] Güncel", $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> <a href=\"http://
>| www.ntvmsnbc.com/news/$haber_e[0]\" target=_blank >$haber_e[1]</a></
>| font></br>\n";
>| }
>| }
>| }
>| ?>
If this is only a daily task then I would process the data and store
it in a static html page.
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
[Back to original message]
|