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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:46:47+00:00 2026-06-11T09:46:47+00:00

I have hand coded my blog, no wordpress or anything, and I am trying

  • 0

I have hand coded my blog, no wordpress or anything, and I am trying to make a feature that would allow me to write code in my blog and display it like: <div>Like This</div>
I am probably thinking about it way to much, it might be simpler than I think. What I was trying to do was just find <code></code> tags in the blog post and replace all the < with $lt; and > with &gt;, etc. that were found inside the <code></code> tags. But I could think of a way where it would do it for multiple <code></code> tags.

Then at the very end of the code I would replace <code></code> with <div class="code"></div>

Is there a better way to do this? Thanks guys!

  • 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-06-11T09:46:48+00:00Added an answer on June 11, 2026 at 9:46 am
    <?php
    $html="<code>this is the first code snippet</code><p>This is a normal paragraph</p><code>this is the second code snippet</code>";
    preg_match_all("'<code>(.*?)</code>'si", $html, $match);
    if ($match) {
        foreach ($match[1] as $snippet) {
                echo htmlspecialchars($snippet, ENT_QUOTES);
                echo "\n";           
        }
     }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never hand-coded object creation code for SQL Server and foreign key decleration
I have a rails application that patches ActiveRecord with a hand-coded validator. The patch
Task at hand — I have three versions of some code, developed by different
Problem : I have a hand held device that scans those graphic color barcodes
I have a C application I'm converting from a set of hand coded Makefiles
I have an existing site (where nearly every line has been coded by hand)
So I have a hand-coded one-pager site with a very long length and dozens
I have a website with a blog and sidebar on the right hand side
I have worked on websites before and always hand coded in each. But as
Possible Duplicate: Java, GUI builder or hand coding? I have been making GUI hand-coded

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.