Cut something without problems
$width=1300; $height=169; preg_match_all('~(?<=<p>)<iframe.*</iframe>(?=</p>)~Uis',$htm,$arr); $ifr=preg_replace('~(.*height=")[\d]+(" width=")[\d]+(")~i','$1%2$d$2%1$d$3',$arr[0][0]); // если иной порядок параметров $ifr=preg_replace('~(.*width=")[\d]+(" height=")[\d]+(")~i','$1%1$d$2%2$d$3',$ifr); // меняем "высоту"/"ширину" $ifr=sprintf($ifr,$width,$height); echo $ifr; // тут iframe
not the most elegant code, but convenient
principle: we cut out <p>
replace the width and height values with descriptors. What for? I suppose html will be stored in the database, so the processed html to $ifr=sprintf($ifr,$width,$height);
save And when you need to display a video of the desired size, we call sprintf
indicating the desired height and width.