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 7066601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:04+00:00 2026-05-28T05:06:04+00:00

Using PHP I need I will have an array of tag name => tag

  • 0

Using PHP I need I will have an array of tag name => tag URL I need to somehow scan a text input (will be somewhat large, a blog post) and find all tag names in the text and replace them with the URL link. To complicate it though, if the tag name is inside <h1>, <h2>, or <code> and <pre> tags it will not do it. Possibly to simplify, I could say it has to be inside a <p> tag for the switch to take place.

I am not sure how to accomplish this, I know I will need regex but I am a bit lost at the moment, if anyone could help me some I would greatly appreciate it

so a PHP tag would be turned into <a href="link here">PHP</a>

  • 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-28T05:06:04+00:00Added an answer on May 28, 2026 at 5:06 am

    You can use an XML parser like:

    $array_of_tags = (array) simplexml_load_string($html);
    

    OR

    $xml_object = simplexml_load_string($html);
    

    The first approach will give you your tags in a searchable array. The second will give you a SimpleXMLElement object.

    You can then use a simple foreach loop to iterate over the elements in your array or reference the variables in your SimpleXMLElement object. Have a look at the simplexml_load_string tutorial by W3C it’s very straight forward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice from experts :) I will develop a website using PHP
I found that using Smarty with PHP, sometimes extra time will need to be
PROBLEM I have a nested PHP array that I need to populate from flat
I am writing a PHP function that will need to loop over an array
I'm using php and need to do a bunch of select statements on the
Hey, I'm using php 5 and need to communicate with another server that runs
I need to create a web application using php, I had many users having
I am using PHP. I need to store the multiple values at a single
I need to export a report to Excel file using PHP i.e. on the
i need to know how can i connect telephone using php languages

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.