Please tell me, I have studied the regulars a little while, but I tried to do the following: /\d+.+\d/ I need to check if there is a number with a dot in the string, if yes, then add to the array

  • You are not the person who is trying to determine in this way, an integer or not? And then there was a case here)) - ModaL
  • The plus sign means "one or more characters." Those. you incorrectly put a plus sign. - lampa

2 answers 2

I apologize of course, but the is_float function accepts mixed $ var

If you still want a regular season - /^\d+\.\d+$/

 ^ - начало строки \d - любая цифра + - 1 или более \. - просто точка. Если написать без слеша, то любой символ. $ - конец строки. 
  • one
    and floatval () also returns the same found number :) Hammer on a regular season, only lose performance - Johny

Not simpler:

 preg_match_all('/([0-9]+\.[0-9]+)/isu',$html, $array); 
  • one
    You are the flags of the isu set? Parentheses are not needed because ts only checks entry. [0-9] it is better to replace it with \ d, it looks kosher. the function itself must be replaced by preg_match. - lampa
  • Oops, read inattentively. If only for the presence, then of course you are right. I always put these flags, regardless of the situation. - Arc
  • @Arc well read the manual on the flags. The "s" flag is far from doing what was expected. - lampa