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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:26:40+00:00 2026-06-11T17:26:40+00:00

First, thanks for helping me out here, I really appreciate your time. Let me

  • 0

First, thanks for helping me out here, I really appreciate your time.

Let me give you a little background on what I’m trying to accomplish:

I’m working on a small site enhancement where I want to add a simple related posts widget within the content area of certain posts.

Now, for any given post, I have all of my post content stored in a variable. Let’s call it $content.

What I’m hoping to do is parse this $content string and insert the widget immediately after the second instance of an H3 tag.

This is an example of one of my failed attempts:

$widgetizedContent = explode("</h3>", $content);
$widgetizedContent[1] .= 'widget code';
$finalContent = implode($widgetizedContent, "<p>");

I’m not really sure where to go from here, and would appreciate any direction you could provide me.

Edit: This is the output:

<h3>This is my header text[this is the text I'm trying to insert]</h3>

Instead of inserting the widget code after the H3, it’s inserting it before the closing H3 tag. I don’t think I understand implode as well as I should:)

  • 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-11T17:26:41+00:00Added an answer on June 11, 2026 at 5:26 pm

    Based on your code, you can add text after the second </h3> by pre-pending the text to the content after the tag (rather than the content before).

    $widgetizedContent = explode("</h3>", $content);
    $widgetizedContent[2] = 'widget code'.$widgetizedContent[2] ;
    $finalContent = implode("</h3>", $widgetizedContent);
    

    Of course this blindly assumes there will be at least 2 </h3> tags, which may or may not suit your site.

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

Sidebar

Related Questions

first of all thanks for taking your time! I'm a junior Dev, working with
Hey, first of all thanks for helping me out with this (probably stupid) question
Right first of I would like to thank everyone for helping me out on
First of all thanks for taking the time to look into this. I store
First, thanks in advance for taking the time to read through this. I have
Hello there freaks & geeks. Here comes my question again, thanks for helping!. Lets
Greetings all, First of all thank you all for helping me out with my
I have been really puzzled because I was trying to work out some jQuery
Thanks to @cool_me5000 for helping me out with an overly simplified version of this
Helping out a friend here, and thought I would play with programming an iPad.

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.