<?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/"
	>

<channel>
	<title>Codes Tips</title>
	<atom:link href="http://codestips.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codestips.com</link>
	<description>Tips &#38; Tutorials for everyone who loves programming</description>
	<pubDate>Sat, 05 Dec 2009 12:34:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP downloadable file</title>
		<link>http://codestips.com/php-downloadable-file/</link>
		<comments>http://codestips.com/php-downloadable-file/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 21:40:13 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=319</guid>
		<description><![CDATA[Text downloadable file
Last days I needed to create a file which had to be downloaded by many users. The file had to be in plain text and contents from file come from database. Because I didn&#8217;t had a separate folder for each user I couldn&#8217;t write the information to a file to the server and [...]]]></description>
			<content:encoded><![CDATA[<h2>Text downloadable file</h2>
<p>Last days I needed to create a file which had to be downloaded by many users. The file had to be in plain text and contents from file come from database. Because I didn&#8217;t had a separate folder for each user I couldn&#8217;t write the information to a file to the server and put a link in order the user to download it. I thought a little bit how to handle it and found a very simple solution to to make a file downloadable to users. I even try to other popular formats like .doc, .xls,.csv,.dat and it works really nice. Extension that I tested it and  didn&#8217;t worked are .xlsx and .pdf.</p>
<p>In order to make a file downloadable you should modify the header of the page to make <strong>Content-type: application/octet-stream</strong> and <strong>Content-Disposition: attachment; filename=\&#8221;downloadableFile.extension\&#8221; </strong> in order  to inform the browser that there is an attachment binary file. The file will open in a window to inform the user it to open it with a default application or save it to disk.<br />
Code for downloadable file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>downloadablefile.txt<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">echo</span> <span style="color: #0000ff;">'Contents of plain text downloadable file'</span><span style="color: #339933;">;</span>  
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>CSV downloadable file</h2>
<p>The real magic comes when you wanna make csv file downloadable. You can read data from a mysql table and write the contents to a csv file. You should only read contents from a table and using echo output to the file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>downloadablefile.csv<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
			or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Database CONNECT Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
 		<span style="color: #000088;">$resultcsv</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_db_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$database</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;select * from <span style="color: #006699; font-weight: bold;">$csvTable</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultcsv</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
		<span style="color: #009900;">&#123;</span> 
			<span style="color: #990000;">echo</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;City&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>Excel downloadable file</h2>
<p>Code for generating a excel downloadble file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>downloadableFile.xls<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
			or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Database CONNECT Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
 		<span style="color: #000088;">$resultxls</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_db_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$database</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;select * from <span style="color: #006699; font-weight: bold;">$xlsTable</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultxls</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
		<span style="color: #009900;">&#123;</span> 
			<span style="color: #990000;">echo</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;City&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can look through records from database and output as I did for csv</p>
<h2>Doc downloadable file</h2>
<p>You can even make a downloadable .doc files by changing the file extension to doc.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>downloadablefile.doc<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">echo</span> <span style="color: #0000ff;">'Contents of Word Document.'</span><span style="color: #339933;">;</span>  
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<div id="ratebox_319" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '319');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '319');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+downloadable+file&amp;Description=PHP+downloadable+file&amp;Url=http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+downloadable+file&amp;url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+downloadable+file&amp;u=http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-downloadable-file/&amp;T=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-downloadable-file/&amp;title=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-downloadable-file/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-downloadable-file/&amp;t=PHP+downloadable+file" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-downloadable-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP string manipulation 3</title>
		<link>http://codestips.com/php-string-manipulation-3/</link>
		<comments>http://codestips.com/php-string-manipulation-3/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 21:00:01 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=298</guid>
		<description><![CDATA[This is the third part about how to manipulate strings in PHP.
Replace all occurrences of sub strings with a replacement string
If you wanna replace all occurrence of a substring inside a string you should use the function str_replace passing as first argument the string(or array of strings) you wanna search, second argument the string(or array [...]]]></description>
			<content:encoded><![CDATA[<p>This is the <strong>third part</strong> about how to manipulate strings in PHP.</p>
<h2>Replace all occurrences of sub strings with a replacement string</h2>
<p>If you wanna replace all occurrence of a substring inside a string you should use the function <b>str_replace</b> passing as first argument the string(or array of strings) you wanna search, second argument the string(or array of strings) you wanna make the replace, the third is the string you wanna search in and the fourth argument is the number of replacements the function should make. It returns a string after all replacements have been made.<br />
<b>Declaration</b>: <i>mixed <b>str_replace</b> ( mixed $SearchFor, mixed $ReplaceWith , mixed $String[, int &#038;$number] )</i><br />
<b>Example</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a str_replace Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$searchFor</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Function&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replaceWith</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;function&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$searchFor</span><span style="color: #339933;">,</span><span style="color: #000088;">$replaceWith</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Output</b>: This is a str_replace function test</p>
<h2>Split string one by one</h2>
<p>To tokenize string in php you can you the function <b>strtok</b> in order to split a string. Each smaller string it&#8217;s separated by a delimeter. It takes as a first argument the string that will be split and the second the delimeter that it is used to split it.<br />
You should call the first time the function as strtok($String,$delimiter) and returns the first string that is delimited. Any subsequent calls of the function should be like strto($delimiter(s)), because the function keeps into memory the variable $String that it&#8217;s delimited.<br />
You can specify multiple delimiter<br />
<b>Declaration</b>: string <b>strtok</b>(string $String, string $delimiter(s))<br />
<b>Example</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is an strtok Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tok</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtok</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tok</span> <span style="color: #339933;">!==</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;String=<span style="color: #006699; font-weight: bold;">$tok</span>&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tok</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtok</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//returns the next splitted string in the $string variable</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Output</b>:<br />
String=This<br />
String=is<br />
String=an<br />
String=strtok<br />
String=Function<br />
String=Test</p>
<h2>Split a string by a delimeter</h2>
<p>Disadvantage of strtok function it&#8217;s that you should call it every time you wanna split the string. You can use <b>explode</b> function in order to split the string and returns an array of string with all the string  splitted. The first argument is the delimiter, the second the string you wanna split and you can also specify an optional integer argument that specify the limit of strings splitted.<br />
<b>Declaration</b>: array <b>xplode</b>(string $delimiter , string $String[, int $limit ])<br />
<b>Example</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is an explode Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$explodedstring</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$explodedstring</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$substring</span><span style="color: #009900;">&#41;</span>
 <span style="color: #990000;">echo</span> <span style="color: #000088;">$substring</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Output</b>:<br />
This<br />
is<br />
an explode Function Test</p>
<h2>Union elements of array in a string</h2>
<p>If you wanna join array elements into 1 string you should call the function <b>implode</b>. The first argument that you should pass to the function is the separation and the second one the array of string.<br />
<b>Declaration</b>: string implode ( string $separator , array $Strings)<br />
<b>Example</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$strings</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'is'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'implode'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'function'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$separator</span><span style="color: #339933;">,</span><span style="color: #000088;">$strings</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Output</b>:<br />
This is a implode function test</p>
<h2>Replace a string by regular expression</h2>
<p>You can use regular expression in php to replace using the function <b>preg_replace</b>. You should pass the first argument as a regular expression pattern - it can be a string or an array of string, the second is the string or array of string that you use to replace the pattern, third argument is the string you search in. The final two arguments are optional, first parameter is the limit of replacement you should make and the final one is the value of replacements that have been made in the string.<br />
<b>Declaration</b>: mixed <b>preg_replace</b> (mixed $regularExpression, mixed $replaceWith, mixed $String [, int $limit= -1 [, int &#038;$count ]] )<br />
<b>Example</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a preg_replace bad, words, Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(\w+,)&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replaceWith</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$replaceWith</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b>Output</b>:<br />
This is a preg_replace Function Test</p>
<p><a href="http://www.codestips.com/php-string-manipulation-2/" style="color:red">PHP string manipulation - part 2</a></p>
<div id="ratebox_298" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '298');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '298');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+string+manipulation+3&amp;Description=PHP+string+manipulation+3&amp;Url=http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+string+manipulation+3&amp;url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+string+manipulation+3&amp;u=http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-string-manipulation-3/&amp;T=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-string-manipulation-3/&amp;title=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-string-manipulation-3/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-string-manipulation-3/&amp;t=PHP+string+manipulation+3" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-string-manipulation-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP string manipulation 2</title>
		<link>http://codestips.com/php-string-manipulation-2/</link>
		<comments>http://codestips.com/php-string-manipulation-2/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 22:34:25 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=274</guid>
		<description><![CDATA[This is the second part of the how you can manipulate string in PHP.
Find length of a string
If you want to find out how many characters have a string you can use the function strlen. If you have to pass 1 argument as the string you wish you find out the length and it returns [...]]]></description>
			<content:encoded><![CDATA[<p>This is the <strong>second part</strong> of the how you can manipulate string in PHP.</p>
<h2>Find length of a string</h2>
<p>If you want to find out how many characters have a string you can use the function <strong>strlen</strong>. If you have to pass 1 argument as the string you wish you find out the length and it returns an integer.<br />
<strong>Declaration</strong>: <em>int <strong>strlen</strong>(string text)</em><br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>: 31</p>
<h2>Find a sub string inside a string</h2>
<p>To find a first occurrence of a string inside other you should use the function <strong>strstr</strong> and pass it 2 arguments. First argument should be the string in which you wanna look and the second should be the string you search. It returns part of the first occurrence until the end of the string you search in.<br />
<strong>Declaration</strong>: <em>string <strong>strstr</strong>(string searchIn,string lookfor)</em><br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>: strstr Function Test</p>
<h2>Find a string inside other string(case insensitive)</h2>
<p>To find an occurrence of a string inside another with case insensitive activated you should use the function <strong>stristr</strong>. It has the same parameters as the <strong>strstr</strong>, but it also finds case insensitive strings.<br />
<strong>Declaration</strong>: <em>string <strong>stristr</strong>(string SearchIn, string lookFor)</em><br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>: StrStr Function Test</p>
<h2>Find position of first occurrence of a string inside another</h2>
<p>To find the position of the first occurrence of a string you can use the function <strong>strpos</strong>.  You should pass two arguments. The first parameter is the string you wanna search in and the second is a the string you are looking for. You can specify an additional argument, an offset that indicates from where position the search should begin.<br />
<strong>Declaration</strong>: <em>int <strong>strpos</strong> ( string $SearchIn, mixed $SearchFor[, int $offset= 0 ] )</em><br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>: 11</p>
<h2>Find a position of a string inside another(case insensitive)</h2>
<p>You can use the function <strong>strripos</strong> and it has the same arguments as <strong>strpos</strong>, but it searches for case insensitives.<br />
<strong>Declaration</strong>:  <em>int <strong>strripos</strong> ( string $SearchIn, mixed $SearchFor[, int $offset= 0 ] )</em></p>
<h2>How to return parts of a string</h2>
<p>To return parts of a string you should use the <strong>substr</strong> function and pass it 2 arguments and 1 optional. The first argument is the string you wanna return a part of a string, second is the start position from where you wanna begin crop the string. You can also specify an argument with the length that the function should crop.<br />
<strong>Declaration</strong>: string <strong>substr</strong> ( string $SearchIn , int $from [,int $length])<br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>: is a substr</p>
<h2>Insert after each end of line in string a html <em>br</em> tag</h2>
<p>To insert html tag br after the new lines in a string you can use the function <strong>nl2br</strong>. Function takes one neccessary  argument and one optional. First is a string where it will be inserted the br tag and the second one is a boolean that indicates if the replacement is a XHTML compatible line breaks(default value is TRUE).<br />
<strong>Declaration</strong>: string <strong>nl2br</strong>(string $InsertIn [,bool $isXHTML= true])<br />
<strong>Example</strong>:</p>
<p><strong>Output</strong>:<br />
This is a nl2br&lt;br /&gt;   Function&lt;br /&gt;   Test</p>
<p><a href="http://codestips.com/php-string-manipulation/" style="color:red">PHP string manipulation - part 1</a> - <a href="http://codestips.com/php-string-manipulation-3/" style="color:red">PHP string manipulation - part 3</a></p>
<div id="ratebox_274" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '274');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '274');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+string+manipulation+2&amp;Description=PHP+string+manipulation+2&amp;Url=http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+string+manipulation+2&amp;url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+string+manipulation+2&amp;u=http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-string-manipulation-2/&amp;T=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-string-manipulation-2/&amp;title=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-string-manipulation-2/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-string-manipulation-2/&amp;t=PHP+string+manipulation+2" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-string-manipulation-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP string manipulation</title>
		<link>http://codestips.com/php-string-manipulation/</link>
		<comments>http://codestips.com/php-string-manipulation/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:53:28 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=267</guid>
		<description><![CDATA[This is a first part of PHP string manipulation.
It&#8217;s extremelly useful to know how to manipulate strings in PHP. This tutorial will guide you through how to use the functions that PHP offers.
A string in PHP it&#8217;s defined in php in a variable assigning a single or double quote  value like:
$string = &#8216;This is [...]]]></description>
			<content:encoded><![CDATA[<p>This is a <strong>first part</strong> of PHP string manipulation.<br />
It&#8217;s extremelly useful to know how to manipulate strings in PHP. This tutorial will guide you through how to use the functions that PHP offers.<br />
A string in PHP it&#8217;s defined in php in a variable assigning a single or double quote  value like:<br />
$string = &#8216;This is a test string&#8217;;<br />
$string = &#8220;This is a test string&#8221;;</p>
<h2>Make all letters from string lowercase</h2>
<p>To make every letter of a string in lowercase you should use the function <strong>strtolower</strong> like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a  strtolower Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The ouput will be: this is a strtolower function test</p>
<h2>Make all letters of a string uppercase</h2>
<p>You should use the function <strong>strtoupper</strong> in order to make every letter of the string in uppercase:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a  strtoupper Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The ouput of will be: THIS IS A STRTOUPPER FUNCTION TEST</p>
<h2>Capitalize first letter of each word in a sentence with ucwords</h2>
<p>To make a sentence more estetic we can capitalize first letter of each word in a sentence with the function ucwords().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a  ucwords Function Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span> 
Output: This Is A Ucwords Function Test</pre></div></div>

<p>This function touch only the first letter of each word and leave other characters like they are. We can improve the way how the string is displayed by combining with the strtolower function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ThiS is a  ucwords FunctioN Test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Output will be:This Is A Ucwords Function Test</p>
<h2>Remove tabs,spaces,new lines from beginning and end of a string</h2>
<p>To remove spaces,tabs and new lines from the beginning and end of a string you should use the function trim(). This function accepts as an input a string, that will be cleaned and returns a string without spaces,tabs and new lines.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> <span style="color: #000099; font-weight: bold;">\n</span>This is a  trim Function Test   &quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Output: This is a trim Function Test</p>
<h2>Remove spaces,tabs and new lines from begining of a string</h2>
<p>Similar like trim we can use ltrim to remove spaces,tabs and new lines from the beginning of a string</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> <span style="color: #000099; font-weight: bold;">\n</span>This is a  trim Function Test <span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>  &quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Output: This is a  trim Function Test 		   </p>
<h2>Remove spaces,tabs and new lines from the end of a string</h2>
<p>Similar like ltrim we can use rtrim to remove characters that we don&#8217;t need:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> <span style="color: #000099; font-weight: bold;">\n</span>This is a  rtrim Function Test <span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>  &quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>Remove tags from a string</h2>
<p>To remove tags from a string you should use strip_tags to have a clean string without tags</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;pre&gt;This is a  trim Function Test&lt;/ pre&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://codestips.com/php-string-manipulation-2/" style="color:red">PHP string manipulation - part 2</a></p>
<div id="ratebox_267" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '267');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '267');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+string+manipulation&amp;Description=PHP+string+manipulation&amp;Url=http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+string+manipulation&amp;url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+string+manipulation&amp;u=http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-string-manipulation/&amp;T=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-string-manipulation/&amp;title=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-string-manipulation/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-string-manipulation/&amp;t=PHP+string+manipulation" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-string-manipulation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delphi http post</title>
		<link>http://codestips.com/delphi-http-post/</link>
		<comments>http://codestips.com/delphi-http-post/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 17:42:49 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[Delphi]]></category>

		<category><![CDATA[borland delphi]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=262</guid>
		<description><![CDATA[To post some data through http protocol in Delphi you can use TIDHttp component.
TIDHttp has a function Post that takes 2, first parameter is the url where you wanna post data and the second is the data you need to post.
The first parameter of Post function is a string and the second one is a [...]]]></description>
			<content:encoded><![CDATA[<p>To post some data through http protocol in Delphi you can use <strong>TIDHttp</strong> component.<br />
TIDHttp has a function <strong>Post </strong>that takes 2, first parameter is the <strong>url </strong>where you wanna post data and the second is the <strong>data </strong>you need to post.<br />
The first parameter of Post function is a string and the second one is a TStringList.</p>
<p>Delphi sample code to post data through http. First put in the uses clause <strong>IdHTTP</strong></p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> PostData<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>    param<span style="color: #000066;">:</span>TStringList<span style="color: #000066;">;</span>
       valid<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">;</span>
       url<span style="color: #000066;">,</span>text<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
       http<span style="color: #000066;">:</span>TIDHttp<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
http <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TIDHttp<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
http<span style="color: #000066;">.</span><span style="color: #006600;">HandleRedirects</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #000066;">;</span>
http<span style="color: #000066;">.</span><span style="color: #006600;">ReadTimeout</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">5000</span><span style="color: #000066;">;</span>
param<span style="color: #000066;">:</span><span style="color: #000066;">=</span>TStringList<span style="color: #000066;">.</span><span style="color: #006600;">create</span><span style="color: #000066;">;</span>
param<span style="color: #000066;">.</span><span style="color: #006600;">Clear</span><span style="color: #000066;">;</span>
param<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'parameter1=1'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
param<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'parameter2=2'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
param<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'parameter3=3'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
valid<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #000066;">;</span>
url<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #ff0000;">'http://www.examplesite.com/script.php'</span><span style="color: #000066;">;</span>
 <span style="color: #000000; font-weight: bold;">try</span>
   text<span style="color: #000066;">:</span><span style="color: #000066;">=</span>http<span style="color: #000066;">.</span><span style="color: #006600;">Post</span><span style="color: #000066;">&#40;</span>url<span style="color: #000066;">,</span>param<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
 <span style="color: #000000; font-weight: bold;">except</span>
  <span style="color: #000000; font-weight: bold;">on</span> E<span style="color: #000066;">:</span>Exception <span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #000000; font-weight: bold;">begin</span>
    valid<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #000066;">;</span>
   <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
 <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> valid <span style="color: #000000; font-weight: bold;">then</span>
 PostData<span style="color: #000066;">:</span><span style="color: #000066;">=</span> text
<span style="color: #000000; font-weight: bold;">else</span>
 PostData <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>You can call the function like this:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">textPostData <span style="color: #000066;">:</span><span style="color: #000066;">=</span> PostData<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>This function returns empty string if it was an error posting data, if not it returns the text that is returned from the url that we posted data.</p>
<p>We created a new TIDHttp variable at runtime and put the properties <strong>ReadTimeout</strong> to 5 seconds(timeout of the connection) and <strong>HandleRedirects </strong>to true, because the url where we post data can redirect us to other page from where we get the result.</p>
<div id="ratebox_262" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '262');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '262');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=Delphi+http+post&amp;Description=Delphi+http+post&amp;Url=http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Delphi+http+post&amp;url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Delphi+http+post&amp;u=http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/delphi-http-post/&amp;T=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/delphi-http-post/&amp;title=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/delphi-http-post/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/delphi-http-post/&amp;t=Delphi+http+post" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/delphi-http-post/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP cpanel scripts</title>
		<link>http://codestips.com/php-cpanel-scripts/</link>
		<comments>http://codestips.com/php-cpanel-scripts/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 16:50:17 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=239</guid>
		<description><![CDATA[Intro
To automate an action in PHP for cpanel it&#8217;s very easy. You just need to know some information about your cpanel. You can find this information on your browser link bar.
$cpanel_user - the username that you use to log into your cpanel
$cpanel_password - the password for cpanel.
$cpanel_host - your cpanel host. You can find this [...]]]></description>
			<content:encoded><![CDATA[<h3>Intro</h3>
<p>To automate an action in PHP for cpanel it&#8217;s very easy. You just need to know some information about your cpanel. You can find this information on your browser link bar.</p>
<p><strong>$cpanel_user</strong> - the username that you use to log into your cpanel<br />
<strong>$cpanel_password</strong> - the password for cpanel.<br />
<strong>$cpanel_host</strong> - your cpanel host. You can find this  after you login to cpanel, right before &#8216;http://&#8217; until &#8216;:&#8217;.<br />
<strong>$cpanel_skin</strong> - cpanel skin. You can find this after &#8216;/frontend/&#8217;, default is &#8216;x&#8217;.</p>
<h3>HTML Form</h3>
<p>You can use this html forms to make the scripts for cpanel, you can add your own fields that you need.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form action=&quot;cpaneladd.php&quot; method=&quot;POST&quot;&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;center&quot;&gt;
&lt;b&gt;Cpanel info&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;right&quot;&gt;Cpanel host:
&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;cpanelhost&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;right&quot;&gt;Cpanel username:&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;cpaneluser&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;right&quot;&gt;Cpanel password:&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;cpanelpass&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;right&quot;&gt;Cpanel skin:&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;cpanelskin&quot; values=&quot;x&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;</pre></div></div>

<p>I made a list with some useful functions that you can use for cpanel:</p>
<h3>1. Adding a database in cpanel</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$newdb</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;db_name&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 curl_setopt <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$cpanel_user</span>:
<span style="color: #006699; font-weight: bold;">$cpanel_password</span>@<span style="color: #006699; font-weight: bold;">$cpanel_host</span>:2082/frontend/<span style="color: #006699; font-weight: bold;">$cpanel_skin</span>
/sql/adddb.html?db=<span style="color: #006699; font-weight: bold;">$new_db</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$result</span><span style="color: #339933;">=</span>curl_exec <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 curl_close <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>2. Adding a user to database in cpanel</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">      <span style="color: #000088;">$db_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;dbuser&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;database&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      curl_setopt <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$cpanel_user</span>:
<span style="color: #006699; font-weight: bold;">$cpanel_password</span>@<span style="color: #006699; font-weight: bold;">$cpanel_host</span>:2082/frontend/<span style="color: #006699; font-weight: bold;">$cpanel_skin</span>/
sql/addusertodb.html?user=<span style="color: #006699; font-weight: bold;">{$cpanel_user}</span>_<span style="color: #006699; font-weight: bold;">{$db_user}</span>
&amp;db=<span style="color: #006699; font-weight: bold;">{$cpanel_user}</span>_<span style="color: #006699; font-weight: bold;">{$db}</span>&amp;ALL=ALL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$result</span><span style="color: #339933;">=</span>curl_exec <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       curl_close <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>3. Delete a user in cpanel</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">     <span style="color: #000088;">$userdb</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userdb&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_setopt <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$cpanel_user</span>:
<span style="color: #006699; font-weight: bold;">$cpanel_password</span>@<span style="color: #006699; font-weight: bold;">$cpanel_host</span>:2082/frontend/<span style="color: #006699; font-weight: bold;">$cpanel_skin</span>/
sql/deluser.html?user=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cpanel_user</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$userdb</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$result</span><span style="color: #339933;">=</span>curl_exec <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_close <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>4. Delete a database in cpanel</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">     <span style="color: #000088;">$db</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;db&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_setopt <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$cpanel_user</span>:
<span style="color: #006699; font-weight: bold;">$cpanel_password</span>@<span style="color: #006699; font-weight: bold;">$cpanel_host</span>:2082/frontend/<span style="color: #006699; font-weight: bold;">$cpanel_skin</span>
/sql/deldb.html?db=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$cpanel_user</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$result</span><span style="color: #339933;">=</span>curl_exec <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     curl_close <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div id="ratebox_239" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '239');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '239');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+cpanel+scripts&amp;Description=PHP+cpanel+scripts&amp;Url=http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+cpanel+scripts&amp;url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+cpanel+scripts&amp;u=http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-cpanel-scripts/&amp;T=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-cpanel-scripts/&amp;title=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-cpanel-scripts/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-cpanel-scripts/&amp;t=PHP+cpanel+scripts" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-cpanel-scripts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP xml to csv</title>
		<link>http://codestips.com/php-xml-to-csv/</link>
		<comments>http://codestips.com/php-xml-to-csv/#comments</comments>
		<pubDate>Sat, 23 May 2009 15:48:04 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=234</guid>
		<description><![CDATA[To create a csv file from a xml in PHP 5.0 it&#8217;s very simple, we will just have to write some lines.
We will use the SimpleXML extension that come from PHP 5.0.
SimpleXML reads an entire xml into an object that we can iterate through his properties.
To write to the csv output file we will use [...]]]></description>
			<content:encoded><![CDATA[<p>To create a csv file from a xml in PHP 5.0 it&#8217;s very simple, we will just have to write some lines.<br />
We will use the <strong>SimpleXML</strong> extension that come from PHP 5.0.<br />
<strong>SimpleXML</strong> reads an entire xml into an object that we can iterate through his properties.<br />
To write to the csv output file we will use  <strong>fputcsv</strong>.<br />
<strong>fputcsv</strong> formats a line as csv and writes it to the file.<br />
Suppose we are having this xml named cars.xml:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cars<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>blue<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>red<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>black<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/car<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cars<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>First we should read our xml using <strong>simplexml_load_file</strong> passing the name of the file and returns an object with all the properties and values of the csv:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> simplexml_load_file<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filexml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After reading it we should iterate through all the child nodes of cars and write it to the output file using <strong>fputcsv</strong> specifying the object,delimiter and enclosure. We should first convert the object into an array in order to write it to the csv:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$car</span><span style="color: #009900;">&#41;</span> 
fputcsv<span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #339933;">,</span> <span style="color: #990000;">get_object_vars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$car</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here is the complete source code that converts xml to csv in php 5.0:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$filexml</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'cars.xml'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filexml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> simplexml_load_file<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filexml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$f</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cars.csv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">car</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$car</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    fputcsv<span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #339933;">,</span> <span style="color: #990000;">get_object_vars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$car</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3><a href="http://codestips.com/scripts/xml2csv.zip" style="color:red">Download php source code for converting xml into a csv</a></h3>
<div id="ratebox_234" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '234');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '234');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+xml+to+csv&amp;Description=PHP+xml+to+csv&amp;Url=http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+xml+to+csv&amp;url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+xml+to+csv&amp;u=http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-xml-to-csv/&amp;T=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-xml-to-csv/&amp;title=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-xml-to-csv/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-xml-to-csv/&amp;t=PHP+xml+to+csv" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-xml-to-csv/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP multithreading using cURL</title>
		<link>http://codestips.com/php-multithreading-using-curl/</link>
		<comments>http://codestips.com/php-multithreading-using-curl/#comments</comments>
		<pubDate>Sat, 23 May 2009 11:00:34 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=226</guid>
		<description><![CDATA[If you wanna get some information from servers using the protocols like http or ftp in PHP you can use cURL to do multithreading.
Multithreading is a term used when we do more jobs in parallel.
First I assume you know what cURL is and what you can it. If you are new to cURL, you can [...]]]></description>
			<content:encoded><![CDATA[<p>If you wanna get some information from servers using the protocols like http or ftp in PHP you can use cURL to do multithreading.<br />
Multithreading is a term used when we do more jobs in parallel.<br />
First I assume you know what cURL is and what you can it. If you are new to cURL, you can check one of my article on <a href="http://codestips.com/curl-post-data-php/">posting data with cURL</a> , it will give you a brief intro to cURL.<br />
To create this with cURL you should know what the following PHP functions do:<br />
<strong>curl_multi_init</strong> - initialize a new cURL multi handle. It will return the cURL handle on success and FALSE on error.<br />
<strong>curl_multi_add_handle</strong> — Add a cURL handle to a cURL multi handle.<br />
<strong>curl_multi_exec</strong> — Runs all the curl handle in the cURL multi handle in parallel.<br />
<strong>curl_multi_remove_handle</strong> — Removes a cURL handle from a cURL multi handle.<br />
<strong>curl_multi_close</strong> — close the cURL multi handle.<br />
You will need at least PHP 5.0 installed on your server in order this cURL function to work.</p>
<p>So now that you know what this functions do, we should first create the links to the servers from were we wanna get info. I will assume that we wanna get information from 3 servers simultaneous:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example1.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ftp://example.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example2.com&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After creating the list of links we should initialize the cURL multi handle and adding the cURL handles.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$curlHandle</span> <span style="color: #339933;">=</span> curl_multi_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> addHandle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">ExecHandle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  curl_multi_getcontent <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #990000;">echo</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//remove the sub - handles</span>
  curl_multi_remove_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_multi_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here is the complete code for doing multithreading in php with cURL:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//add a url to the handler</span>
<span style="color: #000000; font-weight: bold;">function</span> addHandle<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$cURL</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_multi_add_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$cURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$cURL</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//execute the handle until the flag passed</span>
<span style="color: #666666; font-style: italic;">// to function is greater then 0</span>
<span style="color: #000000; font-weight: bold;">function</span> ExecHandle<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$curlHandle</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$flag</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//fetch pages in parallel</span>
    curl_multi_exec<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$flag</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flag</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example1.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ftp://example.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example2.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$curlHandle</span> <span style="color: #339933;">=</span> curl_multi_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> addHandle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ExecHandle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  curl_multi_getcontent <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #990000;">echo</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">//remove the handles</span>
  curl_multi_remove_handle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #339933;">,</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_multi_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curlHandle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3><a href="http://codestips.com/scripts/multithread.zip" style="color:red">Download complete source</a></h3>
<div id="ratebox_226" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '226');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '226');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+multithreading+using+cURL&amp;Description=PHP+multithreading+using+cURL&amp;Url=http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+multithreading+using+cURL&amp;url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+multithreading+using+cURL&amp;u=http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-multithreading-using-curl/&amp;T=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-multithreading-using-curl/&amp;title=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-multithreading-using-curl/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-multithreading-using-curl/&amp;t=PHP+multithreading+using+cURL" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-multithreading-using-curl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP ajax cascading dropdown using MySql</title>
		<link>http://codestips.com/php-ajax-cascading-dropdown-using-mysql/</link>
		<comments>http://codestips.com/php-ajax-cascading-dropdown-using-mysql/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:31:29 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[Codes]]></category>

		<category><![CDATA[PHP/MYSQL]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=206</guid>
		<description><![CDATA[To do cascading drop down in php using mysql we can use AJAX. The name AJAX is from asynchronous JavaScript and XML and it&#8217;s a new technique for web development to build rich interactive web application. The power of this technique comes from the fact that it can send to server requests from the client [...]]]></description>
			<content:encoded><![CDATA[<p>To do cascading drop down in php using mysql we can use AJAX. The name AJAX is from asynchronous JavaScript and XML and it&#8217;s a new technique for web development to build rich interactive web application. The power of this technique comes from the fact that it can send to server requests from the client side, in order to not reload the page. The object that is using AJAX to send and retrieve data between server and the client is named XmlHttpRequest.<br />
To build a cascading drop down in php to retrieve data from a mysql server we will first populate a drop down with the results from a first table from a mysql database. The first table is linked with a second table by a field. When we change the drop down we should assign to OnChanging event  an Javascript function that will populate the second drop down . The function will create a new XmlHttpRequest object and make a call to other php script, grab data and populate the second drop down. The script that it&#8217;s called will fetch the results for that field that was changed.</p>
<p>Watch a demo here:<a href="http://codestips.com/TestScripts/CascadingDropDown/ajaxdropdown.php" style="color:red" target="_blank">populate drop down using ajax</a></p>
<h3><a href="http://codestips.com/scripts/cascadingdropdown.zip" style="color:red">Download php cascading drop down using mysql</a></h3>
<div id="ratebox_206" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '206');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '206');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+ajax+cascading+dropdown+using+MySql&amp;Description=PHP+ajax+cascading+dropdown+using+MySql&amp;Url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=PHP+ajax+cascading+dropdown+using+MySql&amp;url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=PHP+ajax+cascading+dropdown+using+MySql&amp;u=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;T=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;title=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/php-ajax-cascading-dropdown-using-mysql/&amp;t=PHP+ajax+cascading+dropdown+using+MySql" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/php-ajax-cascading-dropdown-using-mysql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delphi usefull string functions</title>
		<link>http://codestips.com/delphi-usefull-string-functions/</link>
		<comments>http://codestips.com/delphi-usefull-string-functions/#comments</comments>
		<pubDate>Sun, 10 May 2009 22:24:11 +0000</pubDate>
		<dc:creator>Codes Tips</dc:creator>
		
		<category><![CDATA[Delphi]]></category>

		<category><![CDATA[borland delphi]]></category>

		<guid isPermaLink="false">http://codestips.com/?p=203</guid>
		<description><![CDATA[This is a list of functions to handle strings in Delphi. It will be update periodically.
Function Stream to String.
If you wanna convert a stream to a string you need to create a TMemoryStream variable and use the function SetString to put the result string

function StreamToString&#40;Stream : TStream&#41; : String;
var ms : TMemoryStream;
begin
  Result := [...]]]></description>
			<content:encoded><![CDATA[<p>This is a list of functions to handle strings in Delphi. It will be update periodically.</p>
<p><strong><strong>Function Stream to String</strong>.</strong><br />
If you wanna convert a stream to a string you need to create a TMemoryStream variable and use the function SetString to put the result string</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> StreamToString<span style="color: #000066;">&#40;</span>Stream <span style="color: #000066;">:</span> TStream<span style="color: #000066;">&#41;</span> <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> ms <span style="color: #000066;">:</span> TMemoryStream<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span><span style="color: #000066;">;</span>
  ms <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TMemoryStream<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">try</span>
    ms<span style="color: #000066;">.</span><span style="color: #006600;">LoadFromStream</span><span style="color: #000066;">&#40;</span>Stream<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">SetString</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>ms<span style="color: #000066;">.</span><span style="color: #006600;">memory</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span>ms<span style="color: #000066;">.</span><span style="color: #006600;">Size</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">finally</span>
    ms<span style="color: #000066;">.</span><span style="color: #006600;">free</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p><strong>Function Replace Char</strong><br />
To replace a char with other character you should make a loop until that char is not find in the string. If it is found in the string then replace with the new character. To find position of a character in a string you should use the function pos and return the position in the string where it was found. If it was not found pos returns -1</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ReplaceChar<span style="color: #000066;">&#40;</span>s<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>c<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #000066;">;</span>charrep<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
 <span style="color: #000000; font-weight: bold;">begin</span>
   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #000066;">pos</span><span style="color: #000066;">&#40;</span>c<span style="color: #000066;">,</span>s<span style="color: #000066;">&#41;</span>&gt;<span style="color: #0000ff;">0</span> <span style="color: #000000; font-weight: bold;">do</span>
       s<span style="color: #000066;">&#91;</span><span style="color: #000066;">pos</span><span style="color: #000066;">&#40;</span>c<span style="color: #000066;">,</span>s<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#93;</span><span style="color: #000066;">:</span><span style="color: #000066;">=</span>charrep<span style="color: #000066;">;</span>
    ReplaceChar<span style="color: #000066;">:</span><span style="color: #000066;">=</span>s<span style="color: #000066;">;</span>   
 <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p><strong>Function Remove Tags</strong></p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> RemoveTags<span style="color: #000066;">&#40;</span>s<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> k1<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span>
     s1<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span>
     canwrite<span style="color: #000066;">:</span><span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
&nbsp;
 s1<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #ff0000;">''</span><span style="color: #000066;">;</span>
 canwrite<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> k1<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #0000ff;">1</span> <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #000066;">length</span><span style="color: #000066;">&#40;</span>s<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span>
 <span style="color: #000000; font-weight: bold;">begin</span>
   <span style="color: #000000; font-weight: bold;">if</span> s<span style="color: #000066;">&#91;</span>k1<span style="color: #000066;">&#93;</span><span style="color: #000066;">=</span><span style="color: #ff0000;">'&lt;'</span> <span style="color: #000000; font-weight: bold;">then</span>
     canwrite<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #000000; font-weight: bold;">false</span>
   <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #000000; font-weight: bold;">if</span> s<span style="color: #000066;">&#91;</span>k1<span style="color: #000066;">&#93;</span><span style="color: #000066;">=</span><span style="color: #ff0000;">'&gt;'</span> <span style="color: #000000; font-weight: bold;">then</span>
        canwrite<span style="color: #000066;">:</span><span style="color: #000066;">=</span><span style="color: #000000; font-weight: bold;">true</span>
      <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #000000; font-weight: bold;">begin</span>
        <span style="color: #000000; font-weight: bold;">if</span> canwrite <span style="color: #000000; font-weight: bold;">then</span>
         s1<span style="color: #000066;">:</span><span style="color: #000066;">=</span>s1<span style="color: #000066;">+</span>s<span style="color: #000066;">&#91;</span>k1<span style="color: #000066;">&#93;</span><span style="color: #000066;">;</span>
       <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
  RemoveTags<span style="color: #000066;">:</span><span style="color: #000066;">=</span>s1<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<div id="ratebox_203" style="height: 18px;"><b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'like', '203');">Like</a></a> - <b><a style="color:red; text-decoration: underline;cursor: pointer;" onclick="loadContent(this, 'dislike', '203');">Dislike</a></a></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=Delphi+usefull+string+functions&amp;Description=Delphi+usefull+string+functions&amp;Url=http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Delphi+usefull+string+functions&amp;url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Delphi+usefull+string+functions&amp;u=http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;FURL"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u=http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;Kaboodle"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/kaboodle.png" title="Add to&nbsp;Kaboodle" alt="Add to&nbsp;Kaboodle" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://codestips.com/delphi-usefull-string-functions/&amp;T=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://netvouz.com/action/submitBookmark?url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions&amp;popup=no" rel="nofollow" title="Add to&nbsp;Netvouz"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/netvouz.png" title="Add to&nbsp;Netvouz" alt="Add to&nbsp;Netvouz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.simpy.com/simpy/LinkAdd.do?href=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Simpy"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/simpy.png" title="Add to&nbsp;Simpy" alt="Add to&nbsp;Simpy" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.squidoo.com/lensmaster/bookmark?http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;Squidoo"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/squidoo.png" title="Add to&nbsp;Squidoo" alt="Add to&nbsp;Squidoo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://codestips.com/delphi-usefull-string-functions/&amp;title=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://codestips.com/delphi-usefull-string-functions/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://codestips.com/delphi-usefull-string-functions/&amp;t=Delphi+usefull+string+functions" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://codestips.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://codestips.com/delphi-usefull-string-functions/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
