V
V
Vladimir Murachev2016-12-05 16:06:40
PHP
Vladimir Murachev, 2016-12-05 16:06:40

How to parse number between tags and text?

Hello dear! Save who can ..
There is a page: https://www.reformagkh.ru/myhouse/profile/view/7720435
Need to parse text : residential, units. 66, namely the number " 66 " Used
simple_html_dom

<?php
  include_once('lib/curl_query.php');
  include_once('lib/simple_html_dom.php');

  $html = curl_get('https://www.reformagkh.ru/myhouse/profile/view/7720435');
  
  $dom = str_get_html($html);

  $curses = $dom->find('.colspan <table class="col_list">'); 


  foreach($curses as $cours) {

    echo $cours->plaintext . '<br>' ;

  }




?>

As a result, I get
largest, units 13 smallest, units 13
residential units 66 non-residential units 3
total area of ​​residential premises, sq. m 3 631.10 total area of ​​non-residential premises, sq. m 627.80 total area of ​​premises included in the common property, sq
. m m 1 855.00 parking area within the boundaries of the land plot, sq.m 0.00
children's playground Not available sports ground Not available other Not completed

And that's it .. Tell me where to dig or poke your nose how to do it .. Regards

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Volf, 2016-12-05
@pabloesco

Well, for example like this:

$a = "Строка с числом 55 и текстом";
$b = (int)preg_replace('/\D/', '', $a);
var_dump($b);

R
Rsa97, 2016-12-05
@Rsa97

preg_match('/жилых, ед\. (\d+)/', $string, $matches);
$value = $matches[1];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question