fork download
  1. <?php
  2.  
  3. function get_string_between($string, $start, $end){
  4. $string = ' ' . $string;
  5. $ini = strpos($string, $start);
  6. if ($ini == 0) return '';
  7. $ini += strlen($start);
  8. $len = strpos($string, $end, $ini) - $ini;
  9. return substr($string, $ini, $len);
  10. }
  11.  
  12. $fullstring = '<div class="quotecontent">This is the message with a lot of text</div>
  13.  
  14. <div class="quotecontent">This is more text here we go</div>
  15.  
  16. <div class="quotecontent">another quote is here</div>
  17.  
  18. <div class="quotecontent">Text is here and we have to count it</div>
  19.  
  20. <div class="quotecontent">This is the message with a lot of text</div>';
  21.  
  22. $parsed = get_string_between($fullstring, 'content">', '</div>');
  23.  
  24. $parsed_clean = strip_tags($parsed);
  25.  
  26. echo str_word_count($parsed_clean);
  27.  
  28. ?>
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
9