1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

AHREF from .txt file in PHP page

Discussion in 'PHP' started by sunnankar, Feb 24, 2010.

  1. #1
    Ok, here is the issue I have. I have .txt files that populate the page with content. I want to go in and add a hyperlink to some of the anchor text in the text file. Obviously, if I have to split up .txt files then it will be a major pain in the behind. Here is an example of what happens when I add the <a href> tag to the .txt file. Any suggestions on how to fix this? Thanks.

    [​IMG]
     
    sunnankar, Feb 24, 2010 IP
  2. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think it depends on the PHP code that gathers the content from the files, we will need it to help you.
     
    ThomasTwen, Feb 24, 2010 IP
  3. sunnankar

    sunnankar Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think this is the relevant part. I can muddle around in HTML but am very new to PHP.

    <? 
    			if(file_exists("files/".$page_name.".txt"))
    			{
    				$file_arr = file("files/".$page_name.".txt");
    				for($line=0;$line<sizeof($file_arr);$line++)
    				{	
    					$curr_line = $file_arr[$line];
    					$str = "***";
    					$res = strncmp($curr_line, $str, 3);
    					if($res==0)
    					$i++;
    		
    					if($res!=0 && $i==($valpage-1))
    					{
    						$res = explode(":",$file_arr[$line]);
    						if(count($res)>1)
    						echo '<strong>'.$res[0].' : </strong>'.$res[1].'<br/>';
    						else
    						echo $curr_line.'<br/>';
    					}	
    				}	
    			}
    		?>
    PHP:
     
    sunnankar, Feb 24, 2010 IP