-1

I have a long string and part of that string is this: <span itemprop="ratingValue">9.26</span>. I want to get 9.26 as a string (using explode?). Thanks for any help. PS: it is html code saved as string.

Jetamo
  • 11
  • 2

1 Answers1

0

Using preg_match():

$input = 'verylongstring<withother>random</withother>
          tags<span itemprop="ratingValue"><9.26</span>';
preg_match('~<span itemprop="ratingValue">(.*?)</span>~', $input, $output);
echo $output[1]; // 9.26
Tom Udding
  • 2,264
  • 3
  • 20
  • 30