Share on Google+Share on Google+

php array explode

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

Advertisements

Posted on: October 28, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.