Wednesday, February 6, 2013

PHP Explode tutorial

PHP Explode tutorial

Syntax:

$array=explode(delimter,inputString);

Splits  input string into an Array. or Converts a input String into an Array using explode function.

Example 1

$inputString= "Hello world this is PHP programmers conference!";

//Here delimiter space ' '
$strArr = explode(' ',$inputString);

print_r($strArr);




Example 2

echo "<br>Example 2<br>";
$str = "1,2,3,4,5,6";
$strArr = explode(' ',$str);
print_r($strArr);


//output  


Array ( [0] => 1,2,3,4,5,6 ) 

 

Example 3

 

echo "<br>Example 2<br>";
$str = "1,2,3,4,5,6";
$strArr = explode(',',$str);
print_r($strArr);

echo "<br>";
echo "Array Sum=".array_sum($strArr);

//output

array_sum:21

PHP Explode tutorial


Tags:PHP Explode tutorial, split input string to an array, convert string to an array,explode input string to an array,converts an input string into an array,php explode,php 5.3.2

No comments:

Post a Comment