note 96889 added to function.preg-replace
| From: | Anonymous at osu1 dot php dot net | Date: | Sun, 21 Mar 2010 16:35:20 +0000 |
| Subject: | note 96889 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167272@lists.php.net to get a copy of this message | ||
Another easy way to extract the width and the height of getimagesize();
<?php
$image = getimagesize($params['tmp_name']);
$pattern = '/^width=\"(?P<width>\d+)\"
height=\"(?P<height>\d+)\"$/';
preg_match($pattern, $image[3], $matches);
?>
This will return the needed values to the $matches array.
(e.g. $matches['width'] and $matches['height'];)
Hope this helps :)
NOTE: I had to change \s with a space in the regular expression because I kept getting the following
error:
"Your note contains a bit of text that will result in a line that is too long, even after using
wordwrap()."
----
Server IP: 217.71.118.186
Probable Submitter: 81.165.158.178
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/96889
Del: integrated -- https://master.php.net/note/delete/96889/integrated
Del: useless -- https://master.php.net/note/delete/96889/useless
Del: bad code -- https://master.php.net/note/delete/96889/bad+code
Del: spam -- https://master.php.net/note/delete/96889/spam
Del: non-english -- https://master.php.net/note/delete/96889/non-english
Del: in docs -- https://master.php.net/note/delete/96889/in+docs
Del: other reasons-- https://master.php.net/note/delete/96889
Reject -- https://master.php.net/note/reject/96889
Search -- https://master.php.net/manage/user-notes.php