regex - preg_replace to replace the number in substring php -


i have below string

$string = 'id="0000001" did="659" interval="2" media.jpg' 

i want replace 2 (value dynamic 0 1000) in interval tag 0. how can it?

i tried following code replaces all

$returnvalue = preg_replace('/\\d+/', '0', $string, -1, $count); 

$returnvalue = preg_replace('/(?<=interval=")\\d+/', '0', $string, -1, $count); 

just include lookbehind stating interval=" should present before \\d+ trying find.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -