Skip to content

Instantly share code, notes, and snippets.

@makingthingswork
Last active November 19, 2020 14:36
Show Gist options
  • Save makingthingswork/68be1a8a25320d70ec5046d0624399d3 to your computer and use it in GitHub Desktop.
Save makingthingswork/68be1a8a25320d70ec5046d0624399d3 to your computer and use it in GitHub Desktop.
Change width and height of HTML (string) element
<?php
function change_dimensions(str, width = '600', height = '450'){
return preg_replace(array('/width="\S+"/i', '/height="\S+"/i'),array(sprintf('width="%s"', width), sprintf('height="%s"', height)), str);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment