Important Definition Script Needed, PLZ!!!
Moderator: General Moderators
Important Definition Script Needed, PLZ!!!
Hello,
Im doing a school project, and it consists of using a definition system, where it scans for all the words on the page, and if it finds any of them from a list, its suppose to print/write/echo w/e to the bottom of the page those words and then create hyperlinks to a definition file thats already built.
I would prefer the script to be written in javascript, or PHP is also terific. Any Help or examples would be most appreceated.
***EXAMPLE***
// Array of words
Lazy, Dog, Jumps
// Content
The quick brown fox jumps over the lazy dog.
// Definitions
Definitions: <a href="define.php?word=Lazy">Lazy</a> | <a href="define.php?word=Dog">Dog</a> | <a href="define.php?word=Jumps">Jumps</a>
Im doing a school project, and it consists of using a definition system, where it scans for all the words on the page, and if it finds any of them from a list, its suppose to print/write/echo w/e to the bottom of the page those words and then create hyperlinks to a definition file thats already built.
I would prefer the script to be written in javascript, or PHP is also terific. Any Help or examples would be most appreceated.
***EXAMPLE***
// Array of words
Lazy, Dog, Jumps
// Content
The quick brown fox jumps over the lazy dog.
// Definitions
Definitions: <a href="define.php?word=Lazy">Lazy</a> | <a href="define.php?word=Dog">Dog</a> | <a href="define.php?word=Jumps">Jumps</a>
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
since this is for a school project.. what do you have so far? what have you tried? .. or are you just being lazy?
here's some hints at how it can be done:
use a string searching function, like [php_man]stristr[/php_man], or better yet, [php_man]preg_match[/php_man] or [php_man]preg_match_all[/php_man] works really well in these situations..
reminder to all who would like to post: this is a school project.
here's some hints at how it can be done:
use a string searching function, like [php_man]stristr[/php_man], or better yet, [php_man]preg_match[/php_man] or [php_man]preg_match_all[/php_man] works really well in these situations..
reminder to all who would like to post: this is a school project.
Hello,
So far...I have created a small site that has some conent, and I use switch in php to change my conent on the page and maintain my header/footer. My Header has a javascript Dropdown menu made from Macromedia Fireworks. I have tried a script called "Search and Highlight" which had conflicts with the menu, causeing javascript errors, and since I found the script pretty advance, I didnt persue it to configure it myself.
I have also attempted some of those PHP scripts preg... which i found i needed to created a string varible...which I cant figure it out how I can make all the conent that I switch turn into a varible. I have spent around 8 hours so far on this problem, browsing threw Old Message boards and PHP Man pages. Its definitly not a matter of being lazy. BTW, thankyou for your suggestions, Ill look them up and see if that solves teh problem and repost..
So far...I have created a small site that has some conent, and I use switch in php to change my conent on the page and maintain my header/footer. My Header has a javascript Dropdown menu made from Macromedia Fireworks. I have tried a script called "Search and Highlight" which had conflicts with the menu, causeing javascript errors, and since I found the script pretty advance, I didnt persue it to configure it myself.
I have also attempted some of those PHP scripts preg... which i found i needed to created a string varible...which I cant figure it out how I can make all the conent that I switch turn into a varible. I have spent around 8 hours so far on this problem, browsing threw Old Message boards and PHP Man pages. Its definitly not a matter of being lazy. BTW, thankyou for your suggestions, Ill look them up and see if that solves teh problem and repost..
Hello Again,
I think I may have found a solution about the string varible..I was doing a search of previous posts, and it looks like i can use get conents of anotherfile, and Im wondering if thats what the search should do, instead of checking the page while its bein "compiled", it checks the page that I have set to switch.
I think I may have found a solution about the string varible..I was doing a search of previous posts, and it looks like i can use get conents of anotherfile, and Im wondering if thats what the search should do, instead of checking the page while its bein "compiled", it checks the page that I have set to switch.
Well, i had school today..
But mostly continued lookin for Javascript for, I know that most forums now can use a new method of highlighting to advertise..but it will highlight that perticular word...and not echo then into definitions, and I found it works nicly with dropdown menus...so if worst comes to worst...that ill use, but Im sure there has to be some solution to use php.
But mostly continued lookin for Javascript for, I know that most forums now can use a new method of highlighting to advertise..but it will highlight that perticular word...and not echo then into definitions, and I found it works nicly with dropdown menus...so if worst comes to worst...that ill use, but Im sure there has to be some solution to use php.
Yes, I understand..you guys arent here to give away full scripts...Im sure people want reinbursed, but Im sure there has to be someone that has tryied to go to the max of what php/javascript can do...any tips on how to "Scan" the page for the perticular words...I did try to use preg_* but they only described string varibles...code thats in varibles...unless i can say page.html = string then have it check the string..it aint goin to work...
Alright, lets see if I can find a perticular code...
How do I change String to read a page.html file and then scan the page for the perticular words and then have it write those words on the bottom of the page I have the code on...or heck save time and just have it scan the whole page for words... by saying string = index.php
Code: Select all
<?php
$string = "April 15, 2003";
$pattern = "/(\w+) (\d+), (\d+)/i";
$replacement = "\${1}1,\$3";
echo preg_replace($pattern, $replacement, $string);
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
please use
Code: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url]
read the function descriptions on this page: http://www.php.net/manual/en/ref.filesystem.php