On Wed, Dec 17, 2008 at 10:38 PM, Velda <[email protected]> wrote:
> Kirk Cerny wrote:
>>
>> preg_replace
>> http://us.php.net/preg_replace
>
>
> Thanks Kirk.  I really need to get better at this stuff.
>
> In case anyone else comes across this archive,  I decided to do the grunt
> work with a series of mysql replaces.  This was to fix broken images I had
> after importing to Wordpress from Nucleus.
>

In case anyone else comes across this archive, here's how to do it
with preg_replace :)

<?php

$source = 'blah blah blah <%image(someimage.jpg|300|225|some image
caption)%>  blah blah blah
blah blah blah <%image(someimage.jpg|900|5|some image caption)%>  blah
blah blah';

echo preg_replace(
        '#<%image\(([^\|]+)\|([0-9]+)\|([0-9]+)\|([^\|]+)\)%>#',
        '<img src="\1" width="\2" height="\3" alt="\4" />',
        $source);

?>

justin
-- 
http://justinhileman.com

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to