I have this code:
$text = '[iframe=200x200]http://stackoverflow.com[iframe] ';
$text = preg_replace(
'/\[iframe=(.*?)x(.*?)\](.*?)\[\/iframe\]/ms',
'<iframe style="border: 1px solid rgb(204, 204, 204); width: \1px; height: \2px;" src="\3"></iframe>',
$text
);
echo $text;
Why is it not working?
Try:
There were some unwanted slashes in
\[\/iframe\]which needed to be changed to\[iframe\]EDIT:
Actually your input string looks incorrect, as it does not have a closing iframe tag:
should be
In cases where your string contains
/you can make use of some other delimiter to make avoid escaping/found in the string. Something like: