SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how do i define a Variable thats in an HTML(another file)?

    My basic question here is how do i define a Variable thats in a HTML file located within the URL links?
    The thing is that the entire HTML 'content' is ALREADY defined by these 2 lines in index.php:

    PHP Code:
    define("FILE""index.htm");
    $content = @ file_get_contents(FILE); 
    for a more detail explanation, i'm in this situation:

    i have a file called index.php which grabs all the content from index.htm and changes '__track___' to a specified variable (eg. k=blahblah when passed from another url to index.php by 'tracker=blahblah')

    Now my variable '$content' contains all the index.htm,
    i would now like to replace all the '&amp' with ';' that are located after in 'url=' (eg. href='exit.php?url=http://www.sampleurl.com/x/?a=s&r=t&f=6&u=9&__track__')

    so i would now like to define that '$url' is the 'url=' in '$content'

    atm it looks like this
    PHP Code:
    $content str_replace("&"";"$content); 
    and it replaces all the &amp's with ; but i wanted just the ones in 'url='



    Hope some understands my 'plain' english

  2. #2
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think i made it more complicated than it sounds.
    i'll try again:

    If i grab the contents of index.htm so it is now printed using the variable $contents - is it possible to replace &amp's with semi-colons that are located in the HTML under 'url='?

  3. #3
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not define all $url links in index.htm using semi-colon instead of ampersand to begin with?

  4. #4
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because i get the links from a 3rd party so i don't want to have to edit them each time, just copy and paste

    and each link contains multiple &amp's that won't pass through when i try to track the clicks external links, and i've been trying to use urlencode and it doesn't work (unknown)

    so at the moment i have 3 files that go like this

    index.php - grabs index.htm, replaces variables in links for some keyword tracking
    index.htm - website content
    exit.php - contains script to log external link clicks

    should i post the script for these?

  5. #5
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adnetmedia
    because i get the links from a 3rd party so i don't want to have to edit them each time, just copy and paste
    So then search/replace in a textfile before you paste
    Seriously though, I think you'd need some sort of regex for this in which case I won't be of much help...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •