Can anyone help me decipher why the following code only works on the first instance of width / height in an object code. I need to replace both the style which use “height: xxx ; width : xxx” and then also replace the actual embed’s height = “xxx” and width = “xxx”
here’s the preg replace:
$vid_object = preg_replace('~((width)\s?[=:]\s?[\'"]?)[0-9]+~i','${1}600',$vid_object);
$vid_object = preg_replace('~((height)\s?[=:]\s?[\'"]?)[0-9]+~i','${1}364',$vid_object);
here’s the video output:
<object style="height: 364px; width: 600px"><param name="movie" value="http://www.youtube.com/v/UF06-2Q0-G0?version=3"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/v/UF06-2Q0-G0?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></object>
I think it has something to do with the replacement part of the code ‘${1}600’ or that the results are limited to first instance.
Any help is greatly appreciated. Wasted too much time hunting when regex isn’t my specialty.
Thanks
nicholas
try
It’s a little broader.
When I run that on the code you provided I get