Home Tutorial Php Phparray php array explode

 
 

php array explode
Posted on: October 28, 2009 at 12:00 AM
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

Related Tags for php array explode :


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.