Page 1 of 1

i run scrip the character is not full

Posted: Mon Dec 10, 2007 5:37 am
by oabbster
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?
      $filetxt = "test.txt";
      $keyword_cut = ".html";
      $cutn = strlen($keyword_cut);
      $fp = fopen($filetxt,"r");
         
         $data = NULL;

      while(!feof($fp)) {
            
         $data .= fread($fp,8192);

      }

      $line = explode("\n",$data);
      
      $i=0;
      while($i<count($line)) {
         if(trim($line[$i])) {
         print '<a href="' . trim($line[$i]) . '">' . str_replace('-',' ',substr(trim($line[$i]),0,'-' . $cutn)) . '</a><br>';
      
      }
         $i++;
      }

?>



test.txt

7-tips-for-better-ads
9-tips-for-better-billboards
a-cluttered-ad-kills
ad-placement
ads-dont-sell-people-do


be like this , the character is not full


7 tips for bette
9 tips for better billb
a cluttered ad
ad plac
ads dont sell peopl



correct ?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Dec 10, 2007 6:46 am
by VladSun
because of using substr() in this code:

Code: Select all

substr(trim($line[$i]),0,'-' . $cutn)