Log in

View Full Version : Counting keyword on your html page (not form)



tottijohn
07-17-2007, 09:51 AM
Hi, i am relatively new to js, so appreciate all the help.

Lets say i want to count the total number of times the word "three" appears on my page and display the counted number, is that possible? Been searching high and low but all seems to involve counting words only in form.

Thanks and regards

djr33
07-17-2007, 09:57 AM
This would be possible using PHP.


<?php
$file = file_get_contents('thispage.php');
$num = substr_count($file,'myword')-1;
//subtract one for the actual word in the above line
echo $num;
?>

I'm not sure if this is possible with Javascript, though it would be fairly slow and hard to setup, I think.

tottijohn
07-18-2007, 02:15 AM
Thanks, guess its time for me to start learning PHP