i run scrip the character is not full

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oabbster
Forum Newbie
Posts: 1
Joined: Mon Dec 10, 2007 5:23 am

i run scrip the character is not full

Post 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]
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

because of using substr() in this code:

Code: Select all

substr(trim($line[$i]),0,'-' . $cutn)
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply