<?php function resize_image($content) { return preg_replace_callback('/width=["\']([\d]+)["\']/', function($match) { return "width='".$match[1] * 0.7."'"; }, $content); } //Kullanımı echo resize_image('<img src="foo.jpg" width="800">');