search and replace in php string

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 29, 2011   (RSS)

By zaba - July 29, 2011

Hi not really cms builder question, more of a php thing.

I have a field in my database "video_ref" that the client can put embed information for videos either from youtube or other sources.

The video will appear in 2 different places at 2 different sizes. The video dimensions in the input code will vary.

What I want is to be able to search the following or similar code looking for all instances of width="whatever" and height="whatever" and replace them with specific dimensions. this I can perform on the different pages requiring different sizes.

typical code returned for <?php echo $vidrecord['video_ref'] ?>would be:
<object id="flashObj" width="294" height="180" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"><param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="videoId=1085261241001&playerID=64461390001&playerKey=AQ~~,AAAADvh-Hkk~,yxKZp3GImt74tvNzevDAR8IIfqlagIoN&domain=embed&dynamicStreaming=true" /><param name="base" value="http://admin.brightcove.com" /><param name="seamlesstabbing" value="false" /><param name="allowFullScreen" value="true" /><param name="swLiveConnect" value="true" /><param name="allowScriptAccess" value="always" /><embed src="http://c.brightcove.com/services/viewer/federated_f9?isVid=1" bgcolor="#FFFFFF" flashVars="videoId=1085261241001&playerID=64461390001&playerKey=AQ~~,AAAADvh-Hkk~,yxKZp3GImt74tvNzevDAR8IIfqlagIoN&domain=embed&dynamicStreaming=true" base="http://admin.brightcove.com" name="flashObj" width="294" height="180" seamlesstabbing="false" type="application/x-shockwave-flash" allowFullScreen="true" swLiveConnect="true" allowScriptAccess="always" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>

hope this makes sense. any php help would be appreciated!