Skip to content
Advertisement

PHP regular expression start and end with given number [closed]

I have a string like this 202009170439051466017152d0bd457094b54f32eb029c4e9111725 I need to select the 1466017152 from that. (start with 146 and ending on 10 char)

Can anyone help me out from this?

Advertisement

Answer

Just find the first index of 146 and get substring using substr function starting from that index to total length of 10 chars.

$a ="202009170439051466017152d0bd457094b54f32eb029c4e9111725";

echo substr($a, strpos($a,"146"), 10);

Output:
1466017152
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement