<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3266981836379899219</id><updated>2011-11-27T16:50:42.660-08:00</updated><category term='video'/><category term='height'/><category term='dimensions'/><category term='image'/><category term='width'/><category term='scale'/><category term='php'/><category term='function'/><title type='text'>Progressive Applications</title><subtitle type='html'>Web Dev Blog - contact at www.progressiveapps.com</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://progressiveapps.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://progressiveapps.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ProgressiveApps</name><uri>http://www.blogger.com/profile/16251289052839789355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='5' src='http://2.bp.blogspot.com/_9GRBBGo9qz8/SpnaNhw4oYI/AAAAAAAAAAM/Be8RJsK7wR8/S220/papps_logo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3266981836379899219.post-1689840056051429923</id><published>2010-06-24T01:30:00.000-07:00</published><updated>2010-06-24T01:33:00.593-07:00</updated><title type='text'>Parse a query string into an array of key/value pairs using PHP</title><content type='html'>&lt;div&gt;If you happen to need to parse a query string that is not a part of the current http request, here is a function that will do that. It's pretty basic, you may wish to add url encode checking, but the pattern works great and returns an associative array of the key, value pairs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;function get_query_vars($query_str){&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;$pairs = array();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;$parts = explode('&amp;amp;',$query_str);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;for($i=0,$n=count($parts);$i&lt;$n;$i++)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;if(stristr($parts[$i],"=")){&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;$pair=explode('=',$parts[$i]);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;$pairs[$pair[0]]=$pair[1];&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;return $pairs;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3266981836379899219-1689840056051429923?l=progressiveapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://progressiveapps.blogspot.com/feeds/1689840056051429923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://progressiveapps.blogspot.com/2010/06/parse-query-string-into-array-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1689840056051429923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1689840056051429923'/><link rel='alternate' type='text/html' href='http://progressiveapps.blogspot.com/2010/06/parse-query-string-into-array-of.html' title='Parse a query string into an array of key/value pairs using PHP'/><author><name>ProgressiveApps</name><uri>http://www.blogger.com/profile/16251289052839789355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='5' src='http://2.bp.blogspot.com/_9GRBBGo9qz8/SpnaNhw4oYI/AAAAAAAAAAM/Be8RJsK7wR8/S220/papps_logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3266981836379899219.post-3343970840428426087</id><published>2009-08-29T18:33:00.000-07:00</published><updated>2009-08-29T18:52:55.576-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='function'/><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='width'/><category scheme='http://www.blogger.com/atom/ns#' term='height'/><category scheme='http://www.blogger.com/atom/ns#' term='scale'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='dimensions'/><title type='text'>PHP scale_to function to scale a series of values such as an image or video height and width</title><content type='html'>Need to scale a series of values based on one of the values in proportion to a master value. This is good if you have an image or video that you want to display in proportion, but at a larger or smaller scale.&lt;br /&gt;&lt;br /&gt;Parameter one is an array of numeric values such as: $dims = array(100,75);&lt;br /&gt;The first index may be width and the second the height of an image, but this function will accept an unlimited amount of indexes.&lt;br /&gt;&lt;br /&gt;Parameter two is the master value to use when creating the scale ratio: $master_value = 1000;&lt;br /&gt;&lt;br /&gt;Parameter three is the index of of the array $dims that the function will use to create the master ratio: $master_value_index = 0;&lt;br /&gt;&lt;br /&gt;scale_to(array(100,75),1000,0); would return an array with the values (1000,750). Since the ratio of the specified master index is 10 to 1, 75, and any other values besides the master value are all multiplied by 10.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;function scale_to($dims,$master_value,$master_value_index)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if(!is_array($dims))return false;&lt;br /&gt;if(!is_int($master_value))return false;&lt;br /&gt;if(!is_int($master_value_index)||&lt;br /&gt;   $master_value_index&lt;0||&lt;br /&gt;   $master_value_index&gt;count($dims)-1)return false;&lt;br /&gt;&lt;br /&gt;$ratio = $master_value / $dims[$master_value_index];&lt;br /&gt;&lt;br /&gt;foreach($dims as $k=&gt;$v)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;$new_dims[$k] = $master_value_index == $k ?$master_value : round($dims[$k] * $ratio);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return $new_dims;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3266981836379899219-3343970840428426087?l=progressiveapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://progressiveapps.blogspot.com/feeds/3343970840428426087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://progressiveapps.blogspot.com/2009/08/php-scaleto-function-to-scale-series-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/3343970840428426087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/3343970840428426087'/><link rel='alternate' type='text/html' href='http://progressiveapps.blogspot.com/2009/08/php-scaleto-function-to-scale-series-of.html' title='PHP scale_to function to scale a series of values such as an image or video height and width'/><author><name>ProgressiveApps</name><uri>http://www.blogger.com/profile/16251289052839789355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='5' src='http://2.bp.blogspot.com/_9GRBBGo9qz8/SpnaNhw4oYI/AAAAAAAAAAM/Be8RJsK7wR8/S220/papps_logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3266981836379899219.post-1651666041579030429</id><published>2009-04-22T17:19:00.000-07:00</published><updated>2009-04-22T17:29:44.632-07:00</updated><title type='text'>PHP - How to remove a HTML element property value</title><content type='html'>It's pretty simple but I know regular expressions can be tough sometimes. The code below will remove the width property regardless if it's value is enclosed with single or double quotes.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;$str = preg_replace('/width\s*=\s*["\'].*["\']/','',$str);&lt;/blockquote&gt;Let's put it into a function and change width to a variable so that this code is more flexible:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;function remove_property($property,$str){&lt;br /&gt;return preg_replace('/'.$property.'\s*=\s*["\'].*["\']/','',$str);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$str = '&amp;lt;img src="image.jpg" width="200" height="230"&amp;gt;';&lt;br /&gt;$stripped_string = remove_property('width',$str);&lt;br /&gt;&lt;/blockquote&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3266981836379899219-1651666041579030429?l=progressiveapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://progressiveapps.blogspot.com/feeds/1651666041579030429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://progressiveapps.blogspot.com/2009/04/php-how-to-remove-html-element-property.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1651666041579030429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1651666041579030429'/><link rel='alternate' type='text/html' href='http://progressiveapps.blogspot.com/2009/04/php-how-to-remove-html-element-property.html' title='PHP - How to remove a HTML element property value'/><author><name>ProgressiveApps</name><uri>http://www.blogger.com/profile/16251289052839789355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='5' src='http://2.bp.blogspot.com/_9GRBBGo9qz8/SpnaNhw4oYI/AAAAAAAAAAM/Be8RJsK7wR8/S220/papps_logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3266981836379899219.post-1163738295191281845</id><published>2009-04-22T16:01:00.001-07:00</published><updated>2009-04-22T16:34:06.706-07:00</updated><title type='text'>PHP - extracting tag values from HTML elements</title><content type='html'>Hey all!&lt;br /&gt;&lt;br /&gt;I needed to grab all images out of a text string and then get image property values from that string. I could not use getimagesize() because first I needed the value of the src property anyway.&lt;br /&gt;&lt;br /&gt;      &lt;blockquote&gt;function gather_images($str){&lt;br /&gt;            while(stristr($str,'&lt;img')){ start="strpos($str,'&lt;img');" end="strpos($str,'"&gt;',$start)){&lt;br /&gt;                  $images[] = $cur = substr($str,$start,$end);&lt;br /&gt;                  $str    = str_replace($cur,"",$str);&lt;br /&gt;  }&lt;br /&gt;            return array($str,$images);&lt;br /&gt;      }&lt;/img')){&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So now I've got my image strings in the images[] array. An image string could look something like this &amp;lt;img src="http://www.blogger.com/somefile.jpg" &lt;span style="font-weight:bold;"&gt;width&lt;/span&gt;="100" height="130" /&amp;gt;. The next part is to get a property such as &lt;span style="font-weight:bold;"&gt;width&lt;/span&gt; out of the image string:&lt;br /&gt;&lt;br /&gt;      &lt;blockquote&gt;function get_tag_info($value,$str){&lt;br /&gt; if(preg_match('/'.$value.'\s*=\s*".*"/',$str)){ // if enclosed with " "&lt;br /&gt;  $value = get_tag_value($value,$str,'"');&lt;br /&gt;             }&lt;br /&gt;             else if(preg_match('/'.$value."\s*=\s*'.*'/",$str)){ // if enclosed with ' '&lt;br /&gt;                 $value = get_tag_value($value,$str,"'");&lt;br /&gt;            }&lt;br /&gt;            return $value;&lt;br /&gt;      }&lt;br /&gt;      function get_tag_value($value,$str,$quote){&lt;br /&gt;                $vpos = strpos($str,$value);&lt;br /&gt;                $q1 = strpos($str,$quote,$vpos);&lt;br /&gt;                $q2 = strpos($str,$quote,$q1+1);&lt;br /&gt;                return substr($str,$q1+1,$q2-$q1-1);&lt;br /&gt;      }&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So there you have it, add customization and error handling as you like.&lt;br /&gt;&lt;br /&gt;Ciao&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3266981836379899219-1163738295191281845?l=progressiveapps.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://progressiveapps.blogspot.com/feeds/1163738295191281845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://progressiveapps.blogspot.com/2009/04/php-extracting-tag-values-from-html.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1163738295191281845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3266981836379899219/posts/default/1163738295191281845'/><link rel='alternate' type='text/html' href='http://progressiveapps.blogspot.com/2009/04/php-extracting-tag-values-from-html.html' title='PHP - extracting tag values from HTML elements'/><author><name>ProgressiveApps</name><uri>http://www.blogger.com/profile/16251289052839789355</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='5' src='http://2.bp.blogspot.com/_9GRBBGo9qz8/SpnaNhw4oYI/AAAAAAAAAAM/Be8RJsK7wR8/S220/papps_logo.jpg'/></author><thr:total>0</thr:total></entry></feed>
