1

I have a string:-

<p>my string data <br />
<p>We understand the challenges</p> <strong> that small to medium</strong> my string data my string data my string data </p>

I want remove only first using php plz help

Target as:-

my string data <br />
    <p>We understand the challenges</p> <strong> that small to medium</strong> my string data my string data my string data
Asheesh
  • 161
  • 3
  • 16
  • 1
    Possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – Chris May 06 '16 at 08:22
  • Do you want to remove first tag or first

    tag?

    – Sam Orozco May 06 '16 at 08:41

1 Answers1

0

Guessing you want to remove the first p tag from the string, You can use php trim

$string = '<p>my string data <br />
           <p>We understand the challenges</p> <strong> that small to medium</strong> my string data my string data my string data </p>';

$result_string = rtrim(ltrim(trim($string), '<p>'), '</p>');
echo $result_string;
J.K
  • 1,382
  • 1
  • 11
  • 27