php - preg_replace image tag to other format string -


i have change image tags per php ...

here source string ...

'picture number <img src=get_blob.php?id=77 border=0> howto use' 

the result should this

'picture number #77# howto use'  

i have tested lot, number of image result ... last test ...

$content = 'picture number <img src=get_blob.php?id=77 border=0> howto use'; $content = preg_replace('|\<img src=get_blob.php\?id=(\d+)+( border\=0\>)|e', '$1', $content); 

now $content 77

i hope can me

almost correct. drop e flag:

$content = 'picture number <img src=get_blob.php?id=77 border=0> howto use'; $content = preg_replace('/\<img src=get_blob.php\?id=(\d+)+( border\=0\>)/', '#$1#', $content); echo $content; 

outputs:

picture number #77# howto use 

see documentation more information regular expression modifiers in php.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -