I have div on index page and it is editable.
Below div I have button for post.
On click on button I send div content to another page called file.php
Inside this file I have
$text = $_POST['text'];
Now I need somehow to check how many opening and closing spans I have inside $text
Example:
$text = "<span id='first'>first</span> some text <span id='second'>second</span> more text <span id='third'>third</span>";
Now foreach opened and closed span foreach span do something else... How can I check how many span I have in string and do foreach of them something else...
UPDATE: I tried this:
$html = str_get_html($text);
foreach($html->find('a') as $element){
echo $element->href . '<br>';
}
And I get fatal error for undefined function in str_get_html
'; } But I get fatal error call to undefined function in str_get_html – Careless Apr 26 '16 at 15:13