Important Definition Script Needed, PLZ!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Important Definition Script Needed, PLZ!!!

Post 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>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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..
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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.
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post by Daemon_B »

Please...anyone, any more help would be greatly appreacated..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what have you tried since yesterday?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

post code

Post by neophyte »

Gotta post code...
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

so you haven't coded anything then.. great. :roll:
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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...
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post by Daemon_B »

No, im a coder in training...love to become the best if oppertuinity arose...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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. ;)
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Post Reply