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

<channel>
	<title>Mukesh Chapagain&#039;s Blog &#187; string</title>
	<atom:link href="http://blog.chapagain.com.np/tag/string/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery SQL Wordpress Joomla Programming &#38; Tutorial</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>PHP: Parse Unparse String Array</title>
		<link>http://blog.chapagain.com.np/php-parse-unparse-string-array/</link>
		<comments>http://blog.chapagain.com.np/php-parse-unparse-string-array/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 07:28:49 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=871</guid>
		<description><![CDATA[Here is a quick tip on parsing and unparsing string and array in PHP. You can parses the string into variables by using the parse_str PHP function. Using parse_str function void parse_str ( string $str [, array &#038;$arr ] ) $str = The input string. $arr = If the second parameter arr is present, variables [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-change-the-source-code-and-modifyparse-a-website/' rel='bookmark' title='Permanent Link: How to change the source code and modify/parse a website?'>How to change the source code and modify/parse a website?</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/' rel='bookmark' title='Permanent Link: PHP: How to get integer or decimal from a string?'>PHP: How to get integer or decimal from a string?</a></li>
<li><a href='http://blog.chapagain.com.np/php-javascript-playing-with-multi-dimensional-array/' rel='bookmark' title='Permanent Link: PHP Javascript : Playing with multi-dimensional array'>PHP Javascript : Playing with multi-dimensional array</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here is a quick tip on parsing and unparsing string and array in PHP.</p>
<p>You can parses the string into variables by using the <strong>parse_str</strong> PHP function.</p>
<p><strong>Using parse_str function</strong></p>
<p><span id="more-871"></span></p>
<p><strong>void parse_str  (  string $str  [,  array &#038;$arr  ] )</strong></p>
<p>$str = The input string.<br />
$arr = If the second parameter arr is present, variables are stored in this variable as array elements instead.</p>
<p><strong>Using single parameter</strong></p>
<pre class="brush: php; title: ; notranslate">
$str = &quot;first=value&amp;arr[]=foo+bar&amp;arr[]=baz&quot;;
parse_str($str, $data);
echo $first;  // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz
</pre>
<p><strong>Using the second parameter</strong></p>
<pre class="brush: php; title: ; notranslate">
$str = &quot;first=value&amp;arr[]=foo+bar&amp;arr[]=baz&quot;;
parse_str($str, $data);
echo &quot;&lt;pre&gt;&quot;; print_r($data); echo &quot;&lt;/pre&gt;&quot;;
</pre>
<p>The output will be:-</p>
<pre class="brush: php; title: ; notranslate">
Array
(
    [first] =&gt; value
    [arr] =&gt; Array
        (
            [0] =&gt; foo bar
            [1] =&gt; baz
        )

)
</pre>
<p>You can unparse any array into string using the <strong>http_build_query</strong> function. This generates a URL-encoded query string from the associative (or indexed) array provided. </p>
<pre class="brush: php; title: ; notranslate">
$data = array('foo'=&gt;'bar',
              'baz'=&gt;'boom',
              'cow'=&gt;'milk',
              'php'=&gt;'hypertext processor');

echo http_build_query($data); // foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor
echo http_build_query($data, '', '&amp;amp;'); // foo=bar&amp;amp;baz=boom&amp;amp;cow=milk&amp;amp;php=hypertext+processor
</pre>
<p>Hope this helps. Thanks.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=871&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-change-the-source-code-and-modifyparse-a-website/' rel='bookmark' title='Permanent Link: How to change the source code and modify/parse a website?'>How to change the source code and modify/parse a website?</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/' rel='bookmark' title='Permanent Link: PHP: How to get integer or decimal from a string?'>PHP: How to get integer or decimal from a string?</a></li>
<li><a href='http://blog.chapagain.com.np/php-javascript-playing-with-multi-dimensional-array/' rel='bookmark' title='Permanent Link: PHP Javascript : Playing with multi-dimensional array'>PHP Javascript : Playing with multi-dimensional array</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/php-parse-unparse-string-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: How to get integer or decimal from a string?</title>
		<link>http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/</link>
		<comments>http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 13:32:43 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=768</guid>
		<description><![CDATA[Suppose, I have a string with text and number and I only want the number. I don&#8217;t want the characters and text of the string. Here is the way out:- In this example, you will get only integer. It will omit all characters and text from the string. This example prints decimal numbers removing all [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-simple-and-easy-way-to-format-url-string/' rel='bookmark' title='Permanent Link: PHP: Simple and easy way to format URL string'>PHP: Simple and easy way to format URL string</a></li>
<li><a href='http://blog.chapagain.com.np/php-parse-unparse-string-array/' rel='bookmark' title='Permanent Link: PHP: Parse Unparse String Array'>PHP: Parse Unparse String Array</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-how-to-replace-string-div-content-and-image-src/' rel='bookmark' title='Permanent Link: jQuery: How to replace string, div content and image src?'>jQuery: How to replace string, div content and image src?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Suppose, I have a string with text and number and I only want the number. I don&#8217;t want the characters and text of the string.</p>
<p>Here is the way out:-</p>
<p><span id="more-768"></span></p>
<p>In this example, you will get only <strong>integer</strong>. It will omit all characters and text from the string.</p>
<pre class="brush: php; title: ; notranslate">
$string = 'Nrs 89,994,874.0098';
echo preg_replace(&quot;/[^0-9]/&quot;, '', $string);
// output: 899948740098
</pre>
<p>This example prints <strong>decimal </strong>numbers removing all the characters from the string.</p>
<pre class="brush: php; title: ; notranslate">
$string = 'Nrs 89,994,874.0098';
echo preg_replace(&quot;/[^0-9\.]/&quot;, '', $string);
// output: 89994874.0098
</pre>
<p>Hope this helps.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=768&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-simple-and-easy-way-to-format-url-string/' rel='bookmark' title='Permanent Link: PHP: Simple and easy way to format URL string'>PHP: Simple and easy way to format URL string</a></li>
<li><a href='http://blog.chapagain.com.np/php-parse-unparse-string-array/' rel='bookmark' title='Permanent Link: PHP: Parse Unparse String Array'>PHP: Parse Unparse String Array</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-how-to-replace-string-div-content-and-image-src/' rel='bookmark' title='Permanent Link: jQuery: How to replace string, div content and image src?'>jQuery: How to replace string, div content and image src?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery: How to replace string, div content and image src?</title>
		<link>http://blog.chapagain.com.np/jquery-how-to-replace-string-div-content-and-image-src/</link>
		<comments>http://blog.chapagain.com.np/jquery-how-to-replace-string-div-content-and-image-src/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 05:05:51 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=526</guid>
		<description><![CDATA[In this article, I will be showing you how you can replace string, div content, and image src value with jQuery. You can do this by replace() function in jQuery. View Demo &#124;&#124; Download Code Here is the code to replace string. This will replace the &#8216;smile&#8217; text with &#8216;be happy&#8217;. Here is the code [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/jquery-grey-out-background-and-preview-image-as-popup/' rel='bookmark' title='Permanent Link: jQuery: Grey out background and preview image as popup'>jQuery: Grey out background and preview image as popup</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-animate-and-transfer-effect-with-image/' rel='bookmark' title='Permanent Link: jQuery: Animate and Transfer effect with Image'>jQuery: Animate and Transfer effect with Image</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-preview-image-with-tooltip-effect/' rel='bookmark' title='Permanent Link: jQuery: Preview Image with Tooltip Effect'>jQuery: Preview Image with Tooltip Effect</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-preview-image-with-zoom-effect/' rel='bookmark' title='Permanent Link: jQuery: Preview Image with Zoom Effect'>jQuery: Preview Image with Zoom Effect</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-a-simple-slideshow/' rel='bookmark' title='Permanent Link: jQuery: A simple Slideshow'>jQuery: A simple Slideshow</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this article, I will be showing you how you can replace string, div content, and image src value with jQuery.</p>
<p>You can do this by <strong>replace()</strong> function in jQuery.</p>
<p><span id="more-526"></span></p>
<p><strong><a target="_blank" href="http://blog.chapagain.com.np/examples/replace/">View Demo</a> || <a target="_blank" href="http://chapagain.googlecode.com/files/jquery-replace-string.zip">Download Code</a></strong></p>
<p>Here is the code to replace string. This will replace the &#8216;smile&#8217; text with &#8216;be happy&#8217;.</p>
<pre class="brush: jscript; title: ; notranslate">
var oldText = &quot;Save Earth and smile!&quot;;
var newText = oldText.replace(&quot;smile&quot;, &quot;be happy&quot;);
</pre>
<p>Here is the code to replace image src. The following code replaces &#8216;hills&#8217; with &#8216;sunset&#8217;.</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;.img&quot;).attr(&quot;src&quot;).replace(&quot;hills&quot;, &quot;sunset&quot;);
</pre>
<p>Here is the code to replace div content. The following code replaces the text &#8216;First&#8217; with &#8216;This is the first&#8217;.</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#one&quot;).text().replace(&quot;First&quot;, &quot;This is the first&quot;);
</pre>
<p>Here is the full source code:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;jQuery: Replace&lt;/title&gt;
&lt;script src=&quot;jquery-1.4.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	$(function(){
		$(&quot;#change&quot;).click(function(){
			var newSrc = $(&quot;.img&quot;).attr(&quot;src&quot;).replace(&quot;hills&quot;, &quot;sunset&quot;);
			$(&quot;.img&quot;).attr(&quot;src&quot;, newSrc);			

			var oneDiv = $(&quot;#one&quot;).text().replace(&quot;First&quot;, &quot;This is the first&quot;);
			$(&quot;#one&quot;).text(oneDiv);

			var oldText = &quot;Save Earth and smile!&quot;;
			var newText = oldText.replace(&quot;smile&quot;, &quot;be happy&quot;);
			$(&quot;#two&quot;).text(newText);
		});

		$(&quot;#refresh&quot;).click(function(){
			location.reload();
		});

	});
&lt;/script&gt;
&lt;style&gt;
	#one {
		border: 1px solid #CCCCCC;
		margin: 10px;
		width: 300px;
	}
	#two {
		border: 1px solid #CCCCCC;
		margin: 10px;
		width: 300px;
	}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div align=&quot;center&quot;&gt;
	&lt;img class=&quot;img&quot; src=&quot;hills-thumb.jpg&quot; alt=&quot;image&quot; /&gt;

	&lt;div id=&quot;one&quot;&gt;
	First div.
	&lt;/div&gt;

	&lt;div id=&quot;two&quot;&gt;
	Second div.
	&lt;/div&gt;

	&lt;button id=&quot;change&quot;&gt; Change &lt;/button&gt;
	&lt;button id=&quot;refresh&quot;&gt; Refresh &lt;/button&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong><a target="_blank" href="http://blog.chapagain.com.np/examples/replace/">View Demo</a> || <a target="_blank" href="http://chapagain.googlecode.com/files/jquery-replace-string.zip">Download Code</a></strong></p>
<p>Cheers,</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=526&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/jquery-grey-out-background-and-preview-image-as-popup/' rel='bookmark' title='Permanent Link: jQuery: Grey out background and preview image as popup'>jQuery: Grey out background and preview image as popup</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-animate-and-transfer-effect-with-image/' rel='bookmark' title='Permanent Link: jQuery: Animate and Transfer effect with Image'>jQuery: Animate and Transfer effect with Image</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-preview-image-with-tooltip-effect/' rel='bookmark' title='Permanent Link: jQuery: Preview Image with Tooltip Effect'>jQuery: Preview Image with Tooltip Effect</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-preview-image-with-zoom-effect/' rel='bookmark' title='Permanent Link: jQuery: Preview Image with Zoom Effect'>jQuery: Preview Image with Zoom Effect</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-a-simple-slideshow/' rel='bookmark' title='Permanent Link: jQuery: A simple Slideshow'>jQuery: A simple Slideshow</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/jquery-how-to-replace-string-div-content-and-image-src/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Random number, string generation in PHP</title>
		<link>http://blog.chapagain.com.np/random-number-string-generation-in-php/</link>
		<comments>http://blog.chapagain.com.np/random-number-string-generation-in-php/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:02:22 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2008/03/05/random-number-string-generation-in-php/</guid>
		<description><![CDATA[Explaining/Illustrating different ways to generate random numbers and strings in PHP Copyright &#169; 2011 This feed is for personal, non-commercial use only. The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint: [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/generating-random-image/' rel='bookmark' title='Permanent Link: Generating random image'>Generating random image</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/' rel='bookmark' title='Permanent Link: PHP: How to get integer or decimal from a string?'>PHP: How to get integer or decimal from a string?</a></li>
<li><a href='http://blog.chapagain.com.np/php-parse-unparse-string-array/' rel='bookmark' title='Permanent Link: PHP: Parse Unparse String Array'>PHP: Parse Unparse String Array</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/' rel='bookmark' title='Permanent Link: Magento: Set Random Order in Collection using RAND()'>Magento: Set Random Order in Collection using RAND()</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Explaining/Illustrating different ways to generate random numbers and strings in PHP</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
/*********************************

&lt;span id=&quot;more-43&quot;&gt;&lt;/span&gt;

RANDOM STRING GENERATION

Explaining/Illustrating different ways to generate random numbers and strings

Programmed By: Mukesh Chapagain

http://www.chapagain.com.np

http://blog.chapagain.com.np

*********************************/

//generating random numbers

//generating random numbers between 1 and 1000
$num = rand(1,1000);
echo &quot;Random number from rand function: &quot;;
echo $num;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

//we can use mtrand() function for better random number generation
$mt_num = mt_rand(1,1000);
echo &quot;Random number from mt_rand function: &quot;;
echo $mt_num;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

//generating a unique combination of numbers and letters
//works with PHP5 or higher
$unique = uniqid();
echo &quot;Random string from uniqid function: &quot;;
echo $unique;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

//making the string more complex generated by uniqid function
//by using md5() function
//md5 function generates 32 character long string
//the function uniqid() works only with PHP5 or higher
$md5_unique = md5(uniqid());
echo &quot;Random string from md5 to uniqid function: &quot;;
echo $md5_unique;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

//generating random string from a given string
//randomly shuffling a given string
$string = &quot;Mukesh Chapagain&quot;;
$rand_string = str_shuffle($string);
echo &quot;Random string from str_shuffle function: &quot;;
echo $rand_string;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

//generating random number from time() function
//the number changes every second
//this returns the current unix timestamp
$time = time();
echo &quot;Random number from time function: &quot;;
echo $time;
echo &quot;&lt;br/&gt;&lt;br/&gt;&quot;;

?&gt;
</pre>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=43&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/generating-random-image/' rel='bookmark' title='Permanent Link: Generating random image'>Generating random image</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-integer-or-decimal-from-a-string/' rel='bookmark' title='Permanent Link: PHP: How to get integer or decimal from a string?'>PHP: How to get integer or decimal from a string?</a></li>
<li><a href='http://blog.chapagain.com.np/php-parse-unparse-string-array/' rel='bookmark' title='Permanent Link: PHP: Parse Unparse String Array'>PHP: Parse Unparse String Array</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/' rel='bookmark' title='Permanent Link: Magento: Set Random Order in Collection using RAND()'>Magento: Set Random Order in Collection using RAND()</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/random-number-string-generation-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with strings in PHP (Part 1)</title>
		<link>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/</link>
		<comments>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 04:48:39 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[concatenate]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/12/09/fun-with-strings-in-php-part-1/</guid>
		<description><![CDATA[Problem: Concatenate and fetch data from two fields of database and then break it again. Solution: Posted below. The description is included in the code. You have to make a mysql database. The database part is as under: PHP code below: I have not used any loop (for, while, foreach, etc.) here to make the [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Concatenate and fetch data from two fields of database and then break it again.</p>
<p><strong>Solution:</strong></p>
<p><span id="more-36"></span></p>
<p>Posted below.</p>
<p>The description is included in the code.</p>
<p>You have to make a mysql database. The database part is as under:</p>
<pre class="brush: sql; title: ; notranslate">
create database test;

use test;

create table user(id int(9) not null auto_increment, first_name varchar(20), last_name varchar(20), primary key(id));

insert into user(first_name, last_name) values (&quot;mukesh&quot;,&quot;chapagain&quot;);
</pre>
<p>PHP code below:</p>
<p>I have not used any loop (for, while, foreach, etc.)  here to make the code simple. :-)</p>
<pre class="brush: php; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Fun with strings&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php

// in my configuration, i am running mysql in localhost, my database username is 'root' and i don't have any database password
// i have a table called 'user' in the database 'test'

// connecting to the database server
mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;);

// connecting to the database
mysql_select_db(&quot;test&quot;);

// selecting data from table named 'user' where id = 1
$result = mysql_query(&quot;select concat(first_name,',',last_name) as name from user where id = '1'&quot;);

// fetching the result and assigning it to certain variables
while ($row = mysql_fetch_assoc($result))
{
$name = $row['name'];
echo &quot;$name &lt;br/&gt;&quot;; // you will get the result as first_name,last_name
}
$newName = explode(&quot;,&quot;,$name); // this will make an array with each name as values

//print_r($newName);

// print the first name as
echo &quot;First Name: &quot; . $newName[0] . &quot;&lt;br/&gt;&quot;;

// print the second name as
echo &quot;Second Name: &quot; . $newName[1] . &quot;&lt;br/&gt;&quot;;

// you can find about how many elements/items are there with the commas
$count = count($newName);
echo &quot;Count: $count &lt;br/&gt;&quot;;

// there is a function called 'implode' which will join array elements with a string
$newNameTwo = implode(&quot; &quot;,$newName); // this will print the names with spaces in between... before the names were separated with comma
echo &quot;$newNameTwo &lt;br/&gt;&quot;;

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Happy PHPing!</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=36&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
