Sedang Disiapkan

Random links html output

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   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> | <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.

Kemahiran: PHP

Lihat lebih lanjut: html random link, random link html, php string to html, function calling itself, php random link anchor text, random linkshtml, html random links, randomize links html, php random output html, randomize link html example, php random html output, html random link txt, random html, job links linkshtml, html random link text, html on line, random line program, program output, questions|html, php random file name, random pass, php string contain, output php, retrieve url, url html

Tentang Majikan:
( 4 ulasan ) San Miguel de Salinas, Spain

ID Projek: #339050