Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在数据库中有字段<p>intro content</p><p>rest of content....</p>
<p>intro content</p><p>rest of content....</p>
<p>intro content</p>如何使用 PHP删除第一段内容?
<p>intro content</p>
假设 mysql
SELECT SUBSTRING_INDEX(content_field, '</p>', 1) as cut from TABLE
在数据库中替换:
update [table_name] set [field_name] = replace([field_name],SUBSTRING_INDEX([field_name], '</p>', 1),'');
使用 DOM 解析器。也许PHPQuery。然后,您可以从 DOM 中选择第一个元素并将其删除
伪代码:
$dom->firstChild()->remove();