Regular expression PHP - Text of a site

0

I have a string

Cause value: <'span id="i_valorCausa'">51.899,51<'/span'><'BR'>

I need to get what is between <'span id="i_valorCausa'> <'/span'>

I tried this way:

The $content is where the string comes from.

preg_match_all("/<span id='i_valorCausa'>(.*)<\span>/", $content, $prices); 

echo $prices[1];

But it did not work. Can someone help me?

Thank you in advance.

    
asked by anonymous 06.02.2018 / 18:22

1 answer

1

You should put it as an array like this: ( $prices[1][0]; )

$content = "<span id='i_valorCausa'>hduehuedheudheu<span>";

preg_match_all("/<span id='i_valorCausa'>(.*)<span>/", $content, $prices); 

echo $prices[1][0];

I tested on this website

As stated in the PHP documentation

Parameters pattern The pattern to look for, as a string.

subject The input string.

matches Array of all combinations in multidimensional array ordered according to flags.

As you did not put flag, it will return in an array multidimensional

    
06.02.2018 / 18:38