Let's say that I have a webpage with a lot of text. Let's say that I would like to randomly pick a paragraph and add it (with a rotator) to another page within the same website or to another one in a box. Assuming that what I said above is clear enough to understand, doea anybody have any suggestions? Thanks for any help!
I'll give it a go. This is untested and assumes you have a valid markup with opening and closing paragraph tags around your paragraphs. // grab the source code $filesource = file_get_contents("http://www.example.com/filename.html"); // split it at all the opening paragraph tags $paragraphs = explode("<p>", $filesource); // only go on if there are indeed any paragraphs on that page if (count($paragraphs) > 0) { // get a random number between 1 and the total number of paragraphs. $rand_num = rand(1, count($paragraphs)); // let's work with a random paragraph from that page $paragraph = $paragraphs[$rand_num]; // now split it at the closing paragraph tags $paragraph = explode("</p>", $paragraph); // print the result echo $paragraph[0]; } PHP: You should only have to replace http://www.example.com/filename.html
Wow trevlar! A little more advanced a solution than I expected but it'll give me an opportunity to learn. Thanks very much and don't be surprised if in the next few days I show up with some questions... Thanks! Greenies on their way!