Jump to content

PHP Text Links

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
mmcduffie1

mmcduffie1

    Newbie

  • Members
  • Pip
  • 5 posts
Is there a super simple way to generate text links from a flat file into a specific location on my website?

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Yes, there is. How is the flat-file laid out?

#3
mmcduffie1

mmcduffie1

    Newbie

  • Members
  • Pip
  • 5 posts
i would like to just lay it out as text like
<a href="blah blsh blah>Visit SomeWebsite</a>
. Just basic links to texts or image ads.

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
what's your source? where do you read the links from? database? text file?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
mmcduffie1

mmcduffie1

    Newbie

  • Members
  • Pip
  • 5 posts
the source will be a flat file in the same directory as the script like webaddress/files/adlist.txt

#6
mmcduffie1

mmcduffie1

    Newbie

  • Members
  • Pip
  • 5 posts
I'm trying to get PHP to read the links from a text file and insert them into a section of my webpage. I want to do it this way so I can jst edit one file and change all the ads. Right now i'm just doing an include(). The include() works fine but at some point I may want to limit the amount of links I display so then I need to read the file into an array i think then ad code to show like only 10 links or 20. Does that make any sense? Right now I think I juts need php to read the file into an array i guess and then i need to create a function to add to the page where i want the links to be. I thought I knew how but it seems i do not and my files are at work. If all else fails I will post the code i am trying to get to work tomorrow when I get to my office.

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
You need to read the contents of the file to a string using either file_get_contents or fopen. Then depending on how the data is stored in the file you have several options. You can use the csv functions, explode, or the serialize functions to get the data into an array.
Posted via CodeCall Mobile

#8
mmcduffie1

mmcduffie1

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks everyone. I think I have a clue now. :D