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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:19:45+00:00 2026-05-28T00:19:45+00:00

$text = <p>this is the first paragraph</p><p>this is the first paragraph</p>; I need to

  • 0
$text = "<p>this is the first paragraph</p><p>this is the first paragraph</p>";

I need to split the above into an array delimited by the paragraph tags. That is, I need to split the above into an array with two elements:

array ([0] = "this is the first paragraph", [1] = "this is the first paragraph")
  • 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-28T00:19:46+00:00Added an answer on May 28, 2026 at 12:19 am

    Remove the closing </p> tags as we don’t need them and then explode the string into an array on opening </p> tags.

    $text = "<p>this is the first paragraph</p><p>this is the first paragraph</p>";
    $text = str_replace('</p>', '', $text);
    $array = explode('<p>', $text);
    

    To see the code run please see the following codepad entry. As you can see this code will leave you with an empty array entry at index 0. If this is a problem then it can easily be removed by calling array_shift($array) before using the array.

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

Sidebar

Related Questions

How to strip this text <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> <test@test.com>
I'm following a bioinformatics text, and this represents one of my first Perl scripts.
Is there a CSS code that changes this text This is it to this
i have text like this div bla-bla end div i need to get only
I have the following code txtBlock1.Inlines.Add(This is first paragraph \n This is second paragraph);
I want the first paragraph in the div to be larger text than all
I have this block of html: <div> <p>First, nested paragraph</p> </div> <p>First, non-nested paragraph.</p>
I have a text file, I want to read this text file into 3
In a text file like this: First Name last name # secone name Address
I'm using WCF through Spring.net WCF integration link text This works relatively fine, however

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.