Linked Keywords


Posted on 16th Feb 2014 07:03 pm by admin

I am trying to get a script that makes my predefined keyword converted to links and / or converted to a certain color, size and so on... In one of the other threads Ive posted I got an answer I am a bit curious on, I'll just quote the answer, and hopefully some of you can help me with this.... see my answer below, and help If you want... I'll be forever grateful....

QuoteQuote from: Grayda on Today at 12:26:29 AM
I think I get it. You want certain words to be, say, red. And you want other words to be made in to a link? I think this should help:
Did you know?Explore Trending and Topic pages for more stories like this.


Code:
<?php$mytext = "Buffalo with an aqualung";$mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext);$mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext);echo $mytext

So when you run the script, Buffalo will be replaced with a link to buffalo.php and aqualung will be made bold.

That, of course, is the simple way to do it. You can get complex with regexes and whatnot, but if you're only doing a few things at a time, this is ideal.



bah.. Im still struggling with this... could anyone be helpful explaining to me how I can use this example in my site? I don't understand a thing, and probably shouldn't be messing with this kind of codes.. lol...

Before my text that needs to be converted I have three other pages included:

<?php include "../url/url.php"; ?>
<?php include "url.php"; ?>
<?php include "url/url.php"; ?>

These makes the top of my pages, and I was hoping that I could set the code in one of those so I don't have to copy&paste the script into every single page...

Don't I need any more script than those few lines?

Im desperate.... lol.... please help...
No comments posted yet

Your Answer:

Login to answer
210 Like 51 Dislike
Previous forums Next forums
Other forums

Having Problem with Date
l have a submit buttom where user have the possibility to add a date to specify when his message s

Linux socket programming
Where can I find a good introduction to socket programming?

Forgot password won't work
My forgot password thing is not working properly. It is giving me this errorMailbox unavailable. The

Saving PHP output as a file
I wondered if anyone knows how to save the rendered output of a PHP script as a file?

I have

Edit MySQL Row Using PHP and HTML Form
Hello,

Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.

How to show more than 1 users with this code...
Hello,
i have a table that shows users only if I, as Administrator, want to be shown. But its sho

Get value from Select menu
Hi!

Have tried to find the solution on the web. Don't know if there is an easy one. A descrip

At max how many columns is advisable to create in a table/view
Hi All,
I have two transaction table from which i want to create a simple view or material

Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly.

Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash