Anybody got a little spare time to help me out with a little OOP
| From: | Ryan S | Date: | Sat, 31 May 2008 22:17:34 +0000 |
| Subject: | Anybody got a little spare time to help me out with a little OOP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-274903@lists.php.net to get a copy of this message | ||
coz i suck at OOP!
Hey!
Am trying to modify a wordpress plugin file,the name of the plugin is POST TEASER and can be
downloaded from here http://wordpress.org/extend/plugins/post-teaser/,
it works as advertised and this is what it does:
I specify for
example 4 words before the page should be "cut", it first breaks the
page down into blocks based on the <p> and </p> tags
example
<p> this will be block 1</p>
<p> this will be block 2</p>
<p> this will be block 3</p>
etc
then
it counts the words in block 1, if its equal to the number of words i
specified.. it returns the whole block if not it returns block1 and
block 2 etc...
What i am trying to make it do is... if i specify 3 workds it returns EXACTLY 3
words like so:
"This will be.... read more inside!"
I have written the code to get the above output... but being a total dumbo at OOP i dont know where
to 'insert' the code.
here is the code I have come up with:
================================== Start code ============================================
$sample_string="From http://www.ezee.se/ The UK police are by
far one of the most open to being greedy and corrupted by their afore mentioned greed, case and
point: the hundreds of extra speed cameras that are put in place with an idea of making more money
rather than public safety, cameras that get fines that are around 100 million pounds per year! Heres
one example..";
$words=explode(" ", $sample_string);
$no_to_display=12;
for($i =0; $i < $no_to_display; $i++)
{$make_string_again .= $words[$i]." ";}
echo $make_string_again."... read more inside!";
==================================== end code ===========================================
Have upped the file here if you want to give it a shot.... the script is pretty well self documented
too via comments in the script.
Thanks in advance,
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)