<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thomas Hambach - Web engineer &#187; snippets</title>
	<atom:link href="http://www.rdlt.com/category/snippets/feed" rel="self" type="application/rss+xml" />
	<link>http://www.rdlt.com</link>
	<description>Web development, Web design &#38; Usability</description>
	<lastBuildDate>Mon, 06 Dec 2010 09:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Facebook Error Message: Requires valid next URL.</title>
		<link>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html</link>
		<comments>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html#comments</comments>
		<pubDate>Wed, 16 Jun 2010 09:10:48 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[api error]]></category>
		<category><![CDATA[invalid parameter]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=285</guid>
		<description><![CDATA[Let me start with asking you a few questions! Are you having issues with the Facebook API? Are you constantly getting the error message &#8220;API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL.&#8220;? Are you using the latest official Facebook PHP class? Are you redirecting using the PHP header() [...]]]></description>
			<content:encoded><![CDATA[<p>Let me start with asking you a few questions!</p>
<ol>
<li>Are you having issues with the Facebook API?</li>
<li>Are you constantly getting the error message &#8220;<em>API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL.</em>&#8220;?</li>
<li>Are you using the latest official Facebook PHP class?</li>
<li>Are you redirecting using the PHP <em>header()</em> function?</li>
</ol>
<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2010/06/facebookerror.png"><img class="alignnone size-medium wp-image-286" title="Facebook error" src="http://www.rdlt.com/wp-content/uploads/2010/06/facebookerror-300x119.png" alt="Facebook error" width="300" height="119" /></a></p>
<p>Well,  I might have a solution for you. When calling the function <em>getLoginUrl</em> in the Facebook PHP class, the function will return a HTML encoded string. When outputing this string to your browser, it is rendered/decoded by a browser and this will convert all &#8220;safe&#8221; charachters to their textual equivalent.  This makes that <em>&#8220;&amp;amp;&#8221;</em> becomes &#8220;<em>&amp;</em>&#8221; and <em>&#8220;%20&#8243;</em> becomes &#8221; &#8220;.</p>
<p>However, when using the <em>header()</em> function in PHP, this url will not be rendered/decoded and you are basically sending out a garbled request.</p>
<p><strong>Original</strong></p>
<pre><code class="php">getLoginUrl($params);
header('Location:' . $url);
</code></pre>
<p><strong>Solution:</strong></p>
<pre><code class="php">getLoginUrl($params);
$url = str_replace('&amp;','&amp;',urldecode($url));
header('Location:' . $url);
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>xdebug trace file parser</title>
		<link>http://www.rdlt.com/xdebug-trace-file-parser.html</link>
		<comments>http://www.rdlt.com/xdebug-trace-file-parser.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 18:02:10 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[freebies]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[xdebug]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=241</guid>
		<description><![CDATA[When I am trying to optimize my PHP code, one of my prefered tools is xdebug. It provides me with excellent error messages, outputs code tracing files &#38; insight into memory usage. By using kcachegrind or webgrind &#8211; wincachegrind crashes *all* the time &#8211; to parse the cachegrind files created by xdebug, you get a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-243" title="xdebug_trace_preview" src="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_preview-300x199.png" alt="xdebug_trace_preview" width="300" height="199" /></p>
<p>When I am trying to optimize my PHP code, one of my prefered tools is <a href="http://www.xdebug.org" target="_blank">xdebug</a>. It provides me with excellent error messages, outputs code tracing files &amp; insight into memory usage.</p>
<p>By using kcachegrind or <a href="http://code.google.com/p/webgrind/" target="_blank">webgrind</a> &#8211; wincachegrind crashes *all* the time &#8211; to parse the cachegrind files created by xdebug, you get a good idea of what your code is doing most of the time. It&#8217;ll show you which functions are called, by who, which arguments are passed and tons more. <a href="http://www.xdebug.org" target="_blank">Check it out. </a></p>
<p>Now, there was one small thing I couldn&#8217;t find anywhere. A program to parse the trace files that xdebug generates. True, xdebug already provides the option to output this information into HTML, but it&#8217;s not really what I was looking for. <strong>I want to get quick information in the blink of an eye! </strong>That&#8217;s why I have created my own trace file parser, based on PHP of course.</p>
<h3><span id="more-241"></span>What is it?</h3>
<p>This <strong>xdebug trace parser</strong> will show you, for each function:</p>
<ul>
<li>How much memory was used on entry &amp; exit</li>
<li>How much time it costed to execute the function</li>
<li>The exact line the function was called from plus insight into the code by clicking a link</li>
<li>Whether the function is native PHP or not</li>
</ul>
<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_warning.png"><img class="alignnone size-medium wp-image-245" title="xdebug_trace_warning" src="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_warning-300x54.png" alt="xdebug_trace_warning" width="300" height="54" /></a></p>
<p>It also has a basic &#8220;alerting&#8221; feature, which will allow you to set triggers on memory usage &amp; execution time. You can specifiy that if the memory or time jump is greater than a certain value, to show this in the output.</p>
<h3>Requirements</h3>
<p>It should be obvious that you&#8217;ll need to install and configure xdebug for your PHP installation. See <a href="http://www.xdebug.org" target="_blank">http://www.xdebug.org</a> for more information on this.</p>
<p>Your xdebug config should look a bit like this, don&#8217;t forget to update your paths <img src='http://www.rdlt.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre><code>[XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts="\php\ext\php_xdebug-2.0.4-5.2.8.dll"
xdebug.auto_trace=1
xdebug.trace_format=1
xdebug.profiler_append=1
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=0
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_output_dir="D:\webserver\xdebug"
xdebug.trace_output_name= %t.trace
xdebug.profiler_output_name = %s.%t.profile
xdebug.profiler_output_dir="D:\webserver\xdebug"
</code></pre>
<h3>Download</h3>
<p>Now, give it a try and <a href="../wp-content/uploads/2009/11/trace.zip" target="_blank">downlod the xdebug trace file parser here!</a></p>
<h3>Usage</h3>
<p>Once you&#8217;ve downloaded the trace file parser, extract it to a directory inside your website root and surf to the URL. If everything works out you should be able to select trace files onceyou have ran an other PHP script on your server. This trace file parser will *not* show it&#8217;s own traces because that would make things even more complicated!</p>
<p>Comments &amp; suggestions! <img src='http://www.rdlt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/xdebug-trace-file-parser.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Drupal 5 Views Module Breaks Block Administration</title>
		<link>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html</link>
		<comments>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 11:45:31 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=189</guid>
		<description><![CDATA[While working on a new Drupal 5.19 powered website that has the latest view module enabled, my coworker noticed a strange feature. Once you activated more than one template and tried to switch over to manage the blocks on an other template than garland you will see it switching to garland 50% of the time. [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2009/07/kitten_normal.jpg"><img class="size-thumbnail wp-image-195" title="poor little kitten with big round eyes" src="http://www.rdlt.com/wp-content/uploads/2009/07/kitten_normal-150x150.jpg" alt="poor little kitten with big round eyes" width="150" height="150" /></a> While working on a new Drupal 5.19 powered website that has the latest view module enabled, my coworker noticed a strange feature. Once you activated more than one template and tried to switch over to manage the blocks on an other template than garland you will see it switching to garland 50% of the time.<span id="more-189"></span></p>
<p>The problem here lies in the views module. This module makes a call to the t() function which calls a theme function which eventually has to call init_theme() to check which template it should use. Once the init_theme() funcion has been called, the global variable $theme will be set and any other calls to init_theme() will be . Being called so early in time, the init_theme() function has no idea it still has to switch to a custom theme defined by the blocks module.</p>
<p>The fix involves <a rel="lightbox" href="http://www.vrag.ru/images/news_pic/dead_kitten.jpg">killing a kitten</a>&#8230; also know as <a href="http://drupal.org/node/144376" target="_blank">hacking drupal core</a>. Fire up your favorite editor, open up includes/theme.inc.php and find the following lines of code.</p>
<pre><code class="php">function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  if (isset($theme)) {
    return;
  }
</code></pre>
<p>and replace it with</p>
<pre><code class="php">function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  // patchy patchy!
  if (isset($theme)) {
  	if(isset($custom_theme)) {
  		if($theme == $custom_theme) {
  			return;
  		}
  	} else {
    	return;
  	}
  }</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/drupal-5-views-module-breasks-block-administration.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>memcache_connect() [function.memcache-connect]: Can&#8217;t connect to localhost:11211</title>
		<link>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html</link>
		<comments>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html#comments</comments>
		<pubDate>Mon, 11 May 2009 10:34:06 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=161</guid>
		<description><![CDATA[Encountered this error? It could be as simple as switching the host from localhost to 127.0.0.1 before: &#60;?php $memcache_obj = memcache_connect('localhost', 11211); after: &#60;?php $memcache_obj = memcache_connect('127.0.0.1', 11211);]]></description>
			<content:encoded><![CDATA[<p>Encountered this error? It could be as simple as switching the<strong> </strong>host from <strong>localhost </strong>to <strong>127.0.0.1</strong></p>
<p><strong>before:</strong></p>
<pre><code class="php">&lt;?php
$memcache_obj = memcache_connect('localhost', 11211);</code></pre>
<p><strong>after:</strong></p>
<pre><code class="php">&lt;?php
$memcache_obj = memcache_connect('127.0.0.1', 11211);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Get monday, sunday, last monday &amp; last sunday</title>
		<link>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html</link>
		<comments>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 11:37:32 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=115</guid>
		<description><![CDATA[A function I&#8217;ve put togheter for a work-related project to get date of monday, sunday, last monday &#38; last sunday.. Might add in next monday and sunday later. /** * Get Mondays and Sundays * * Get monday, sunday, last monday &#38; last sunday * Example usage: * // to retreive the dates using today [...]]]></description>
			<content:encoded><![CDATA[<p>A function I&#8217;ve put togheter for a work-related project to get date of monday, sunday, last monday &amp; last sunday.. Might add in next monday and sunday later.</p>
<pre><code class="php">
/**
* Get Mondays and Sundays
*
* Get monday, sunday, last monday &amp; last sunday
* Example usage:
* // to retreive the dates using today as starting point
* $mondaysAndSundays = getMondaysAndSundays();
* // to retreive the dates using a custom date as starting point
* $mondaysAndSundays = getMondaysAndSundays('1987-04-14');
*
* @param date $offset Provide a date from where to calculate from in strtotime() translatable format. If none is given, today's date will be used.
*
* @return array
*
*/
function getMondaysAndSundays($offset=false)
{

if(!$offset) $offset = strtotime(date('Y-m-d'));
else $offset = strtotime($offset);

// this week
if(date('w',$offset) == 1)
{
$mas['monday'] = date('Y-m-d',$offset);
}
else
{
$mas['monday'] = date('Y-m-d',strtotime("last Monday",$offset));
}

if(date('w',$offset) == 6)
{
$mas['sunday'] = date('Y-m-d',$offset);
}
else
{
$mas['sunday'] = date('Y-m-d',strtotime("next Sunday",$offset));
}

// last week
if(date('w',$offset) == 1)
{
$mas['lastmonday'] =  date('Y-m-d',strtotime('-1 week',$offset));
}
else
{
$mas['lastmonday'] = date('Y-m-d',strtotime('-1 week', strtotime(date('Y-m-d',strtotime("last Monday",$offset)))));
}

if(date('w') == 6)
{
$mas['lastsunday'] = date('Y-m-d',strtotime('-1 week',$offset));
}
else
{
$mas['lastsunday'] = date('Y-m-d',strtotime("last Sunday",$offset));
}

return $mas;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>vTiger slow account/products popup</title>
		<link>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html</link>
		<comments>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html#comments</comments>
		<pubDate>Thu, 17 Apr 2008 12:38:59 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[vtiger]]></category>
		<category><![CDATA[adodb]]></category>
		<category><![CDATA[vtiger account]]></category>
		<category><![CDATA[vtiger logging]]></category>
		<category><![CDATA[vtiger popup]]></category>
		<category><![CDATA[vtiger slow popup]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/vtiger-slow-accountproducts-popup.html</guid>
		<description><![CDATA[After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That&#8217;s a huge [...]]]></description>
			<content:encoded><![CDATA[<p>After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That&#8217;s a huge usability issue (read: waste of time) when you are creating invoices or filling out your calendar.</p>
<p>Anyway, all the more reason to place it on my blog, with the all right keywords!</p>
<p>And now, for the solution:</p>
<blockquote><p><em>Quoting <span class="name"><strong>onwealdandy</strong></span></em><br />
<span class="gen"> However, I fixed the performance issue with a work around that doesn’t make much sense, but worked. I read this forum post a few days ago, but couldn’t see how commenting out debug print lines would speed things up. But, that did the trick. However, I did narrow it down to the exact variable causing the ruckus ($list_result) , so I only had to comment out just a few lines in ListViewUtils.php. (any debug log lines with $list_result)</span></p>
<p>Even with logging set to FATAL, the slowness would occur. When you did set logging to DEBUG, one instance would show the correct information in the debug log for the debug log lines .. basically what you would expect when printing $list_result (which is a recordset object) .. the object id &#8230; &#8220;Object id #40&#8243; &#8230; however on the slow machine it would actually print the 2000+ records which were returned by the query.</p>
<p>There must be a bug in php or apache or mysql ( no idea) that returns the entire result set to $list_result when its evaluated for printing. My guess is that the libmysql.dll must have a default _tostring method in there in some versions. BE CAREFUL .. since there its not documented which versions do this &#8230; for the record, my troubled instance was running php5.2.5, apache 2.2.6, and mysql 5.0.45</p></blockquote>
<p>You can find the original vTiger topic here: http://forums.vtiger.com/viewtopic.php?p=64335</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>always_populate_raw_post_data disabled? here&#8217;s a workaround</title>
		<link>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html</link>
		<comments>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html#comments</comments>
		<pubDate>Mon, 11 Feb 2008 17:20:38 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html</guid>
		<description><![CDATA[Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to &#8220;1&#8243;, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative. Appearantly you can use the input wrappers to go around this setting. Perhaps you could find [...]]]></description>
			<content:encoded><![CDATA[<p>Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to &#8220;1&#8243;, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative.</p>
<p>Appearantly you can use the input wrappers to go around this setting. Perhaps you could find this useful in the future</p>
<p>[snippet]&lt;php<br />
if(!$HTTP_RAW_POST_DATA){<br />
$HTTP_RAW_POST_DATA = file_get_contents(&#8216;php://input&#8217;);<br />
if(empty($HTTP_RAW_POST_DATA))<br />
{<br />
// die here<br />
}<br />
}<br />
[/snippet]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>All cities of Belgium with postal code and GPS location</title>
		<link>http://www.rdlt.com/all-cities-of-belgium-with-postal-code-and-gps-location-longitude-latitude.html</link>
		<comments>http://www.rdlt.com/all-cities-of-belgium-with-postal-code-and-gps-location-longitude-latitude.html#comments</comments>
		<pubDate>Sat, 15 Dec 2007 21:20:18 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[free services]]></category>
		<category><![CDATA[freebies]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[belgium]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/all-cities-of-belgium-with-postal-code-and-gps-location-longitude-latitude.html</guid>
		<description><![CDATA[Although, to you foreigners, it may seem like there is not going to be a Belgium in the near future &#8230; For a project of mine, I had to find a database that contained all cities of Belgium with their postal codes and GPS locations (longitude &#38; latitude). Since I couldn&#8217;t find such a database [...]]]></description>
			<content:encoded><![CDATA[<p>Although, to you foreigners, it may seem like there is not going to be a Belgium in the near future &#8230;</p>
<p>For a project of mine, I had to find a database that contained all cities of Belgium with their postal codes and GPS locations (longitude &amp; latitude). Since I couldn&#8217;t find such a database (or I had to pay too f***ing much) I decided to create one myself.</p>
<p>Since I&#8217;m such a commie, I&#8217;ve decided to share this database with anyone that needs it! Please refer to this page to download the database. At this time it&#8217;s only available in Dutch. Maybe some day I&#8217;ll take the time to translate it into english. Maybe some cash would make me work faster? Send your donations to PayPal address: thomas@rdlt.com &#8230;</p>
<p><a href="http://www.rdlt.com/postcodes-van-alle-gemeentes-van-belgie-met-gps-coordinaten">Download database of all cities in Belgium with postal code and GPS location</a>!</p>
<p><a href="http://www.rdlt.com/postcodes-van-alle-gemeentes-van-belgie-met-gps-coordinaten">Download een database met alle steden in België met postcode en GPS locatie</a>!</p>
<p style="text-align: center"><img src="http://www.rdlt.com/wp-content/uploads/2007/12/boitier.thumbnail.jpg" alt="boitier.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/all-cities-of-belgium-with-postal-code-and-gps-location-longitude-latitude.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>best self written PHP function. ever.</title>
		<link>http://www.rdlt.com/best-self-written-php-function-ever.html</link>
		<comments>http://www.rdlt.com/best-self-written-php-function-ever.html#comments</comments>
		<pubDate>Fri, 14 Sep 2007 22:57:15 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/best-self-written-php-function-ever.html</guid>
		<description><![CDATA[Okay, maybe I&#8217;m overrating it, but I still love it for debugging purposes&#8230; unless you are using the CLI. [snippet] function pre($array) { echo &#8216;&#60;pre&#62;&#8217;; echo print_r($array); echo &#8216;&#60;/pre&#62;&#8217;; } [/snippet]]]></description>
			<content:encoded><![CDATA[<p>Okay, maybe I&#8217;m overrating it, but I still love it for debugging purposes&#8230; unless you are using the CLI.</p>
<p>[snippet]<br />
function pre($array)<br />
{<br />
echo &#8216;&lt;pre&gt;&#8217;;<br />
echo print_r($array);<br />
echo &#8216;&lt;/pre&gt;&#8217;;<br />
}<br />
[/snippet]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/best-self-written-php-function-ever.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript str_replace equivalent</title>
		<link>http://www.rdlt.com/javascript-str_replace-equivalent.html</link>
		<comments>http://www.rdlt.com/javascript-str_replace-equivalent.html#comments</comments>
		<pubDate>Fri, 31 Aug 2007 21:47:43 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.rdlt.com/?p=4</guid>
		<description><![CDATA[I needed the equivalent of str_replace in JavaScript and was able to fish up this nifty piece of code! Enjoy. /** * str_replace * * This function returns a string or an array with all occurrences of * [search] in [subject] replaced with the given [replace] value. * If you don't need fancy replacing rules [...]]]></description>
			<content:encoded><![CDATA[<p>I needed the equivalent of str_replace in JavaScript and was able to fish up this nifty piece of code! Enjoy.</p>
<pre><code class="html">/**
* str_replace
*
* This function returns a string or an array with all occurrences of
* [search] in [subject] replaced with the given [replace] value.
* If you don't need fancy replacing rules (like regular expressions), you should always use this function.
*
* @param	string	search
* @param	string	replace
* @param	string	string
*/
function str_replace (search, replace, subject)
{
var result = "";
var  oldi = 0;
for (i = subject.indexOf (search); i &gt; -1; i = subject.indexOf (search, i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/javascript-str_replace-equivalent.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

