Newbie1
Newbie1

Reputation: 37

How to remove first paragraph of content in PHP?

I have got field in database with <p>intro content</p><p>rest of content....</p>

How to remove first paragraph of content <p>intro content</p> using PHP?

Upvotes: 0

Views: 574

Answers (2)

user557846
user557846

Reputation:

assuming mysql

SELECT SUBSTRING_INDEX(content_field, '</p>', 1) as cut from TABLE

replace in db:

update [table_name] set [field_name] = replace([field_name],SUBSTRING_INDEX([field_name], '</p>', 1),'');

Upvotes: 1

dualed
dualed

Reputation: 10512

Use a DOM parser. Maybe PHPQuery. You can then select the first element from the DOM and remove it

Pseudo Code:

$dom->firstChild()->remove();

Upvotes: 1

Related Questions