Reputation: 3073
How to change the width/height if I have the following code and using php:
<iframe src="http://player.vimeo.com/video/43598400"
webkitallowfullscreen=""
mozallowfullscreen=""
allowfullscreen=""
frameborder="0"
height="300"
width="500">
</iframe>
To:
<iframe src="http://player.vimeo.com/video/43598400"
webkitallowfullscreen=""
mozallowfullscreen=""
allowfullscreen=""
frameborder="0"
height="400"
width="680">
</iframe>
Usage is very limited, I want a simple replace solution.
Upvotes: 0
Views: 1860
Reputation: 4828
something like this:
$iframe = '<iframe src="http://player.vimeo.com/video/43598400" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" frameborder="0" height="300" width="500"></iframe>';
$newWidth = 680;
$newHeight = 400;
$iframe = str_replace('height="300"', 'height="' . $newHeight . '"', $iframe);
$iframe = str_replace('width="500"', 'width="' . $newWidth . '"', $iframe);
assuming you are certain that the original width and height will always be 500*300. if not you can try with preg_match()
Upvotes: 3
Reputation: 26861
assuming the variable that holds you string is called $iframe
, try with
str_replace('300', '400', $iframe);
str_replace('500', '680', $iframe);
This is, of course, the most hard coded possible solution - show us more of the context in which this iframe code reside if this doesn't help you
Upvotes: -1