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
Post a Comment