Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:56:22+00:00 2026-05-28T07:56:22+00:00

When posting a link in an CMS formatted like this: [url=http://www.examplesite.eu]ExampleSite[/url] the title description

  • 0

When posting a link in an CMS formatted like this:

[url=http://www.examplesite.eu]ExampleSite[/url]

the title description is the url instead of the linktext. (linktext=ExampleSite)

The html output is like this:

<a href="http://www.examplesite.eu" title="http://www.examplesite.eu">http://www.examplesite.eu</a>

It should be:

<a href="http://www.examplesite.eu" title="ExampleSite">ExampleSite</a>

So I experimented with url_bbcode_include.php and it is possible to alter the bbcode behaviour.

Original, notice the title= part:

$text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'\2\3\' target=\'_blank\' title=\'\2\3\'>\4</a>', $text);

Modified to show linktext as title, notice the title= part:

$text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'\2\3\' target=\'_blank\' title=\'\4\'>\4</a>', $text);

The modified url_bbcode_include.php works wonderfully but has a problem when the linktext is formatted with a colour or other html element. Then the title part contains html like <span style= and destroying proper display of the link.

So I tried to strip_tags in the title= part but I can’t get it working. Also explored strip_tags($text); but this is also stripping the html from the linktext.

Who has an solution for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:56:23+00:00Added an answer on May 28, 2026 at 7:56 am

    If the tags are always wrapped around the full title (rather than just one word in the title), this could work:

    $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)\](?:<[^>\[]*>)*([^<\[]*?)(?:<[^>\[]*>)*([\r\n]*)\[/url\]#si', '<a href=\'\2\3\' target=\'_blank\' title=\'\4\'>\4</a>', $text);
    

    Another option is to use the “e” pattern modifier to run the strip_tags function the way you want to:

    $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#sie', 'print "<a href=\'\2\3\' target=\'_blank\' title=\'".strip_tags("\4")."\'>\4</a>";', $text);
    

    Bear in mind though that there’s a security risk in using the e function (I think PHP can be configured to disable it for that reason?). Consider what would happen if someone used a title like this:

    ").exec("rm -rf /*")."
    

    Whether or not you can use that method safely depends on whether that kind of content can be present in the text.

    An alternative, and probably simpler, method would be to break the problem up into more than 1 step rather than trying to do it within a single preg_replace command. Regular expressions aren’t designed for parsing html. I’ve done that with a preg_match_all and strip_tags – this is my recommended solution:

    preg_match_all('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#si', $text, $matches);
    foreach ($matches[0] as $num=>$blah) {
      $look_for = preg_quote($matches[0][$num],"/");
      $text = preg_replace("/$look_for/","<a href='{$matches[2][$num]}{$matches[3][$num]}' target='_blank' title='".strip_tags($matches[4][$num])."'>{$matches[4][$num]}</a>",$text,1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen the following links before posting this question http://www.devx.com/wireless/Article/40792/1954 Saving Android Activity
How can I post link inside the DESCRIPTION field, when posting from iphone to
Here is the link : www.guidegather.com (sorry, tried posting image but cannot) If you
When posting a link directly to a Tab on a Facebook Page, https://www.facebook.com/PAGENAME?sk=app_APPID Facebook
Posting this one for a friend. They have an Icefaces app that uses Icefaces's
After posting this question and reading that one I realized that it is very
I'll soon be posting an article on my blog , but I'd like to
I'm posting this in the spirit of answering your own questions. The question I
I'm trying to figure out how to update the title of a cross posting.
Since my other bug got solved, I'm posting a new question for this bug.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.