rendered paste body<?php$pattern = '@(width|height)="([0-9]+)"@';$str = "<object width=\"300\" height=\"247\"><param name=\"movie\" value=\"http://www.youtube.com/v/YNb5dfeI93I\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/YNb5dfeI93I\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"123\" height=\"441\"></embed></object>";preg_match_all($pattern, $str, $out, PREG_PATTERN_ORDER);$width = $out[2][0];$height = $out[2][1];$width2 = $out[2][2];$height2 = $out[2][3];if ($height > 150) { $height = 150; $percent = ($height2 / $height); $width = ($width2 / $percent); } else if ($width > 150) { $width = 150; $percent = ($width2 / $width); $height = ($height2 / $percent); } echo $width." ".$height."\n"; $rep = "$1=\"$width\" $2=\"$height\" $3=\"$width\" $4=\"$height\""; echo preg_replace($pattern, $rep, $str);/*OUTPUT:X-Powered-By: PHP/5.2.0Content-type: text/html41.836734693878 150<object width="41.836734693878" 300="150" ="41.836734693878" ="150" height="41.836734693878" 247="150" ="41.836734693878" ="150"><param name="movie" value="http://www.youtube.com/v/YNb5dfeI93I"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/YNb5dfeI93I" type="application/x-shockwave-flash" wmode="transparent" width="41.836734693878" 123="150" ="41.836734693878" ="150" height="41.836734693878" 441="150" ="41.836734693878" ="150"></embed></object>*/?>