[thelist] PHP help with fopen (I think)

Simon Willison cs1spw at bath.ac.uk
Fri Mar 15 16:05:01 CST 2002

Tara Cleveland wrote:

>Okay, so I've got this page (call it "Home"). I want the Home page to open
>another page (call it "text"). I want the Home page to take the first
>sentence on the text page (not a whole HTML page just text), and put it into
>the middle of the Home page.
Here's a simple way of doing that:

$array = file('home.html'); // Read file into an array
$contents = implode('', $array); // Stick the whole file together in to
a single variable
$contents = strip_tags($contents); // Get rid of HTML tags
$bits = explode('.', $array); // Split on full stops
$first_sentence = $bits[0].'.'; // Get first sentence and put a full
stop on the end



More information about the thelist mailing list