Wednesday, July 17, 2013

count special Character (how many time occur) and set inside value in an array.

<?php 

$mystring = "my ,name ,is ,sudhir ,kumar";

$n = strpos($mystring, ',');

//echo substr($mystring, 2, $n)

$myArray = explode(',' ,$mystring);

$num=substr_count($mystring, ',');

for($i=0;$i<=$num;$i++)

{

echo $myArray[$i];

}

?>

No comments:

Post a Comment