search and replace in php string

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

Re: [zaba] search and replace in php string

By Jason - July 29, 2011

Hi,

You could try something like this:

<?php
$heightPattern = "/height=\"[0-9]*\"/";
$widthPattern = "/width=\"[0-9]*\"/";

$vidrecord['video_ref'] = preg_replace($heightPattern, "height='120'", $vidrecord['video_ref']);
$vidrecord['video_ref'] = preg_replace($widthPattern, "width='200'", $vidrecord['video_ref']);
?>


You would then replace "height='120'" and "width=''200'" with what ever values you want.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/