First off my main data is stored in a file called “news.txt” (MySQL is another option but this approach well suits it’s purpose)
It’s contents:
[code]
[color=blue]<!– Start New Post –>[/color]
<!– Start Author –>
Ultimater 6-18-05
<!– End Author–>
<!– Start Clan News –>
<p></p>
<p>Welcome to our new member NightZon! The clan will meet tomorrow at 4:00 eastern time on 6-18-05 in the lounge</p>
<p>
</p>
<!– End Clan News –>
<!– Start Site Update –>
<p></p>
<p>Building a new skin for the site. It will have a glassy look to it.</p>
<!– End Site Update –>
[color=blue]<!– End New Post –>[/color]
[color=blue]<!– Start New Post –>[/color]
<!– Start Author –>
HarryPothead 8-29-05
<!– End Author–>
<!– Start Clan News –>
<p>Congrats to BurningShadow onbehalf of his co-leader promotion</p>
<p>the new ranking system for our clan that involves a system of tests will
(hopefully) be finished in its design by September 1st, its implimentation
date is yet to be set, but it would apear as though a large amount of our
clan aproves of the new system.. where as the old system many people were
objecting to π the new system will hopefully make ranks a more.. apeasing
thing to get involved in, where as before many people were “i have a
rank?! what!?” yeah.. that was not how i want our clan to be</p>
<p>MC raid last night!!! even tho i was realy the only person in it.. but i
will have screenshots added to the WoW shot section asap! enjoy!</p>
<p>
</p>
<!– End Clan News –>
<!– Start Site Update –>
<p></p>
<p>i apologize for not having made a news post for a wile, i dont want this
to be a place where people say.. oh.. the website.. there is nothing usefull
there.. i will work harder to get all important news updates recorded</p>
<p>Ultimater should finish the news blog before long…</p>
<!– End Site Update –>
[color=blue]<!– End New Post –>[/color]
Now I need to parse the data into three major arrays $authors, $clannews, $siteupdates.
Open the above file using PHP, again it’s called “news.txt” and located in the root directory.
Next store all of it’s contents into a scalar variable for PHP to work-with by the name of $template.
Then execute the following regular expression on $template and store all the matches into a new array called $newposts:
[code]
/<!–s*Starts+News+Posts*–>(.*?)<!–s*Ends+News+Posts*–>/igs
Loop through the array $newposts and execute one-by-one the-following-three regular expressions on it.
[code]
/<!–s*Starts+Authors*–>(.*?)<!–s*Ends+Authors*–>/igs (append the matches into an array $authors)
/<!–s*Starts+Clans+Newss*–>(.*?)<!–s*Ends+Clans+Newss*–>/igs (append the matches into an array $clannews)
/<!–s*Starts+Sites+Updates*–>(.*?)<!–s*Ends+Sites+Updates*–>/igs (append the matches into an array $siteupdates)
PHP should now contain 3 major one-dimensional arrays to work-with furthermore.
[code]
[color=blue]$authors[/color]=array(‘Ultimater 6-18-05’, ‘HarryPothead 8-29-05’);
[color=blue]$clannews[/color]=array(‘<p></p>
<p>Welcome to our new member NightZon! The clan will meet tomorrow at 4:00 eastern time on 6-18-05 in the lounge</p>
<p>
</p>’,
‘<p>Congrats to BurningShadow onbehalf of his co-leader promotion</p>
<p>the new ranking system for our clan that involves a system of tests will
(hopefully) be finished in its design by September 1st, its implimentation
date is yet to be set, but it would apear as though a large amount of our
clan aproves of the new system.. where as the old system many people were
objecting to π the new system will hopefully make ranks a more.. apeasing
thing to get involved in, where as before many people were “i have a
rank?! what!?” yeah.. that was not how i want our clan to be</p>
<p>MC raid last night!!! even tho i was realy the only person in it.. but i
will have screenshots added to the WoW shot section asap! enjoy!</p>
<p>
</p>’);
[color=blue]$siteupdates[/color]=array(‘<p></p>
<p>Building a new skin for the site. It will have a glassy look to it.</p>’,
‘<p></p>
<p>i apologize for not having made a news post for a wile, i dont want this
to be a place where people say.. oh.. the website.. there is nothing usefull
there.. i will work harder to get all important news updates recorded</p>
<p>Ultimater should finish the news blog before long…</p>’);
That is all.