This is a very small and simple PHP job and should be very quick and easy for anyone with decent php experience.
I am wanting a php function that can be called from any webpage on any domain. The function will retrieve and return a list of urls and anchor text.
The calling webpage will pass the following paramater3:
1) The name of a text file, for example ?f="list1.txt"
2) The number of links to retrieve. If left blank default to 4
3) A 'separation' string (which may be blank, in which case default to &nbsp; as the separator) that will separate the various links, for example:
The function will
1) Retrieve the named text file from a directory - the directory should be specified as a constant in the function itself so I can change it later if I wish to. A full filepath may be used, or a relative url.
2) Return a string consisting of the (randomly selected) specified number of links. In the text file each link url and anchor text will be on a separate line like this:
<a href="http://example.com">Anchor text</a>
<a href="http://anotherexample.com">Different text</a>
The links should be chosen randomly from the lines in the list (which could contain thousands of lines). Each link should be separated from the next one using the 'separation' parameter passed from the calling program.
If there is only 1 link returned there is no need for the separation text to be added. There should be no separation text after the final link.
For this example separation text the string returned to the calling program should therefore look something like this:
<a href="http://example.com">Anchor text</a>&nbsp;|&nbsp;<a href="http://anotherexample.com">Different text</a>
Finally, the function should simply return nothing if invalid input is passed to it, or if the text file does not exist.
I've given a very detailed description because the right person will see that this is a well specced simple job and should be able to do it very quickly.
If there are any questions please let me know.