3

code for this:

  <span class="file-count-label" ng-init="totalResultCount=304575" ng-show="totalResultCount" style="">304,575</span>

$videos=$html->find('span[class=file-count-label]');
foreach($videos as $e)
{
  echo $e->plaintext;
}

output:{{totalResultCount | number}} but i want 304,575

2 Answers2

2

You can use xpath selector

<?php

$html = '<span class="file-count-label" ng-init="totalResultCount=304575" ng-show="totalResultCount" style="">304,575</span>';
$doc = new DOMDocument;
$doc->loadHTML($html);
$finder = new DomXPath($doc);
$classname="file-count-label";
$videos = $finder->query("//*[contains(@class, '$classname')]");

foreach($videos as $e)
{
  echo $e->nodeValue;
}

Output:- https://eval.in/1056186

Reference taken:- https://stackoverflow.com/a/6366390/4248328

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
0

It works for me:

include 'simple_html_dom.php';
$html = str_get_html('<span class="file-count-label" ng-init="totalResultCount=304575" ng-show="totalResultCount" style="">304,575</span>');

$videos=$html->find('span[class=file-count-label]');
foreach($videos as $e)
{
  echo $e->plaintext; 
  // 304,575
}
pguardiario
  • 53,827
  • 19
  • 119
  • 159