Page 1 of 2

Important Definition Script Needed, PLZ!!!

Posted: Mon Sep 20, 2004 1:15 am
by Daemon_B
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>

Posted: Mon Sep 20, 2004 1:46 am
by feyd
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.

Posted: Mon Sep 20, 2004 2:10 am
by Daemon_B
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..

Posted: Mon Sep 20, 2004 2:29 am
by Daemon_B
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.

Posted: Tue Sep 21, 2004 9:18 pm
by Daemon_B
Please...anyone, any more help would be greatly appreacated..

Posted: Tue Sep 21, 2004 9:27 pm
by feyd
what have you tried since yesterday?

post code

Posted: Tue Sep 21, 2004 9:29 pm
by neophyte
Gotta post code...

Posted: Tue Sep 21, 2004 9:31 pm
by Daemon_B
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.

Posted: Tue Sep 21, 2004 9:33 pm
by feyd
so you haven't coded anything then.. great. :roll:

Posted: Tue Sep 21, 2004 9:35 pm
by Daemon_B
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...

Posted: Tue Sep 21, 2004 9:37 pm
by Daemon_B
No, im a coder in training...love to become the best if oppertuinity arose...

Posted: Tue Sep 21, 2004 9:38 pm
by feyd
you have the content? yes. you have the words? yes. I don't see how the preg_ functions couldn't do this. They're perfect for this kinda work.

if you show us some code, we'll happily nudge you in the right directions.. but we will not do the homework. You won't learn anything real that way. ;)

Posted: Tue Sep 21, 2004 9:43 pm
by Daemon_B
Alright, lets see if I can find a perticular code...

Code: Select all

<?php
$string = "April 15, 2003";
$pattern = "/(\w+) (\d+), (\d+)/i";
$replacement = "\${1}1,\$3";
echo preg_replace($pattern, $replacement, $string);
?>
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

Posted: Tue Sep 21, 2004 9:45 pm
by Daemon_B
Believe me, if you say single code...ill look for it...trust me, ill leave ya alone if one code in php is said here! -please be a good one, :P

Posted: Tue Sep 21, 2004 9:47 pm
by feyd
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