Home Tutorial Php Phparray php array explode

 
 

Share on Google+Share on Google+
php array explode
Posted on: October 28, 2009 at 12:00 AM
Advertisement
This section demonstrates the use of explode function in php

  • Explode function divides the given string into an array of strings
  • It uses the delimiter such as comma tab pipe space and semicolon


Example of PHP Array Explode
<?php
    $animal
="dog,cat,rat";
    echo
$animal;
    echo
"<br>size is ".sizeof($animal);
    $animal1
=explode(",",$animal);
    echo
"<br>after explode";

    foreach
($animal1 as $a)  {
     echo
"<br> ".$a;
    }
    echo
"<br>size is ".sizeof($animal1);
?>

Output

dog,cat,rat
size is 1
after explode
dog
cat
rat
size is 3
Advertisement

Related Tags for php array explode :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 28, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com