•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,123 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,087 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2814 | Replies: 6
![]() |
•
•
Join Date: Feb 2003
Location: London, England
Posts: 281
Reputation:
Rep Power: 7
Solved Threads: 6
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,926
Reputation:
Rep Power: 32
Solved Threads: 118
Hey rob!
Can you explain to me how that's used please?
Can you explain to me how that's used please? Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation:
Rep Power: 5
Solved Threads: 0
Thats now what I mean, I want to be able to detect a plain text URL strait out of some text for example what forums do:
http://www.squarehybrid.com
you will note that I have not placed the [url] tags around them the link has been activated.
http://www.squarehybrid.com
you will note that I have not placed the [url] tags around them the link has been activated.
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,926
Reputation:
Rep Power: 32
Solved Threads: 118
I'm not exactly sure of the PHP code to do this, but the algorithm might be for a string X, search the string until you detect "http://" ... from that on, it is a link until you reach whitespace. For each letter that isn't part of the URL, copy it directly into a new string X2. When you do detect a URL, add the appropriate code before and after it, and then copy it into X2. I think that might be a lot easier than inserting into the middle of the original string. I'm not sure how flexible php is with strings compared to C++ and Java, for example. Since it is a scripting language, however, I would assume it would natively be built to handle strings very well.
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Feb 2003
Location: London, England
Posts: 281
Reputation:
Rep Power: 7
Solved Threads: 6
Oh you could use preg_replace() with some regular expression trickery...
www.php.net/preg-replace
www.regular-expressions.info
www.php.net/preg-replace
www.regular-expressions.info
•
•
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation:
Rep Power: 5
Solved Threads: 0
look at all the PHP functions avalable for doing something like this I have only found two that should work. They are preg_replace and eregi_replace but I only know the basics of how they work. for example
[php]$text = preg_replace("#\[b\](.+?)\[/b\]#i","<b>\\1</b>",$text);[/php]
that would take what ever the value of text is and if it finds [b] (in eather case) it will make the string that is inside bold.
I have looked at the PHP's preg syntaxs (sp) and I don't understand how they work well enough to know what to do.
[php]$text = preg_replace("#\[b\](.+?)\[/b\]#i","<b>\\1</b>",$text);[/php]
that would take what ever the value of text is and if it finds [b] (in eather case) it will make the string that is inside bold.
I have looked at the PHP's preg syntaxs (sp) and I don't understand how they work well enough to know what to do.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Lost browser links,internet options etc...toolbar (Web Browsers)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- IE-links won't always work and will not "open in new window" (Web Browsers)
- Takeout Links Section (DaniWeb Community Feedback)
- general links board? (DaniWeb Community Feedback)
Other Threads in the PHP Forum
- Previous Thread: Having trouble with links on PHP site! Any help would be great!
- Next Thread: PHP Login



Linear Mode