Getting numeric value from URL uol

1

I would like to know how I can use php to get only the numeric value of this UOL image url link in this case only the 15516553 and highlight everything else I need to always take the numeric value always in the same position between / and -medium.

    
asked by anonymous 01.07.2015 / 22:54

1 answer

2

You can use regex for this, eg:

$url = 'http://thumb.mais.uol.com.br/15516553-medium.jpg?ver=1';
preg_match("/^.*(uol.com.br\/)(\d+)-*/", $url, $valores);

echo $valores[2]; // seu id ficará na posição [2]

Output

  

15516553

IdeOne Example

RegEx Analysis

    
01.07.2015 / 23:12