Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect the number of <p> elements stored in my db?

Tags:

html

php

Let's say that I have this text my db.

<P>word1</P>
<P>word2</P>
<P>word3</P>
<P>word4</P>

How I can detect the number of <p> elements after I get my text from my db?

Thanks

like image 357
Saleh Avatar asked Jan 01 '26 07:01

Saleh


1 Answers

Use the Simple HTML DOM parser for PHP to parse the contents of the text, select all 'p' elements, then count the size of the resulting array.

like image 81
Delan Azabani Avatar answered Jan 03 '26 21:01

Delan Azabani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!