Well, I know that I should use the DOM parser, but this should drown out some code, which is a proof of concept for a later function, so I want to quickly get some functions on a limited set of test code.
I am trying to remove the width and height attributes of pieces of HTML, in other words, replace
width="number" height="number"
with an empty string.
The function I'm trying to write looks like this:
function remove_img_dimensions($string,$iphone) {
$pattern = "width=\"[0-9]*\"";
$string = preg_replace($pattern, "", $string);
$pattern = "height=\"[0-9]*\"";
$string = preg_replace($pattern, "", $string);
return $string;
}
But that does not work.
How do I do this job?
source
share