[UPHPU] Re: explode with more than one delimiter?
justin
justin at justinhileman.info
Thu Dec 18 10:34:33 MST 2008
On Wed, Dec 17, 2008 at 10:38 PM, Velda <velda at novapages.com> 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
More information about the UPHPU
mailing list