Hey there! It's a long time ago since using s9y but I'm back
I have a problem with php here and need some help.
Just a small example:
What I have is:
<img src="foo" alt="bar" />
what I need is some php preg_replace or something like that what transforms the
img so that the result would be:
<div title="foo"></div>
Sound strange I know but I need a php solution.
I tried a lot of stuff but I'm not that good in php and less in regex.
Thanks for any help!
Greetings lordcoffee
general php-regex question
-
- Regular
- Posts: 308
- Joined: Tue Nov 29, 2005 10:22 pm
- Location: Munich - Germany
- Contact:
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: general php-regex question
Hi!
HTH,
Garvin
Code: Select all
<?php
$html = '<img src="foo" alt="bar" />';
echo preg_replace('@<img.*src="([^"]+)"[^>]+>@i', '<div title="\1"></div>', $html);
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 308
- Joined: Tue Nov 29, 2005 10:22 pm
- Location: Munich - Germany
- Contact:
Re: general php-regex question
holy sh...
you don't want to know what I have tried
dind't know that it could be that easy
THANKS IN ADVANCE, GARVIN!
greetings, lordcoffee
you don't want to know what I have tried
dind't know that it could be that easy
THANKS IN ADVANCE, GARVIN!
greetings, lordcoffee