Hi everyone. Noob here.
I have a site I’m working on. There will be a news section. The idea is, the client will have access to a text file, and can edit it however they see fit. So I created a text file. For the sake of humor, it’s called balls.txt. For testing purposes, it looks like:
TEST
body
TEST
body
TEST
body
with the “TEST” lines being the editable news entries for the client.
My code in my html looks like this:
<?php
$file = fopen("balls.txt","r");
$balls = fread($file,filesize("balls.txt"));
fclose($file);
$ary = explode("<!--break-->",$balls);
foreach ($ary as $value) {
?>
<div class="text"><? echo $value; ?></div>
<?
}
?>
and it obviously displays:
TEST
body
TEST
body
TEST
body
Now, I want to differentiate between TEST and body text, and make TEST a header or something, like
in the html. How can I go about singling out a single element in the array? I was reading, and it seems the file() function could help with this, but I read that breaks up a text file into an array, but line by line. What if I have the body text being several paragraphs long?
I’d really appreciate any help. Thanks everyone.