Blog Details

explode and implode function


                                
                                    <h2>* PHP  explode() Function :</h2>
<ul>
	<li><span style="font-size: 13px;">The explode() function breaks a string into an array.</span></li>
</ul>
&nbsp;
<h2><strong>Syntax :</strong></h2>
<strong>explode(<em>separator,string,limit</em>)</strong>
<h2><strong>Example :</strong></h2>
&lt;html&gt;
&lt;body&gt;

<span style="color: #ff0000;">&lt;?php
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?&gt;</span>

&lt;/body&gt;
&lt;/html&gt;
<h2><strong>Output :</strong></h2>
Array ( [0] =&gt; Hello [1] =&gt; world. [2] =&gt; It's [3] =&gt; a [4] =&gt; beautiful [5] =&gt; day. )
<h2>* PHP implode() Function :-</h2>
<ul>
	<li><span style="font-size: 13px;">The implode() function <strong>returns</strong> a<strong> string</strong> from the<strong> elements of an array.</strong></span></li>
	<li><strong>Join</strong> array <strong>elements with a string:</strong></li>
</ul>
&nbsp;
<h2><strong>Syntax :</strong></h2>
<h3><strong>implode(<em>separator,array</em>)</strong></h3>
<h2><strong>Example :</strong></h2>
&lt;html&gt;
&lt;body&gt;

<span style="color: #ff0000;">&lt;?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr)."&lt;br&gt;";
echo implode("+",$arr)."&lt;br&gt;";
echo implode("-",$arr)."&lt;br&gt;";
echo implode("X",$arr);
?&gt;</span>

&lt;/body&gt;
&lt;/html&gt;
<h2><strong>Output :</strong></h2>
Hello World! Beautiful Day!
Hello+World!+Beautiful+Day!
Hello-World!-Beautiful-Day!
HelloXWorld!XBeautifulXDay!
                                    


Categories

Core_PHP

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote