Skip to content
Advertisements

PHP Array Functions: explode()

explode (): Used to create a new array by breaking the plain text by the separator to be specified.


  $LIST = "hello my name is truecodes";

  print "<pre>";
  print_r($LIST);
  print "</pre>";


  $LIST_EXPLODE = explode(" ", $LIST);

  print "<pre>";
  print_r($LIST_EXPLODE);
  print "</pre>";
hello my name is truecodes

 Array
(
    [0] => hello
    [1] => my
    [2] => name
    [3] => is
    [4] => truecodes
) 

  $LIST = "hello my name is truecodes";

  print "<pre>";
  print_r($LIST);
  print "</pre>";


  $LIST_EXPLODE = explode(" ", $LIST, 3);

  print "<pre>";
  print_r($LIST_EXPLODE);
  print "</pre>";
hello my name is truecodes

 Array
(
    [0] => hello
    [1] => my
    [2] => name is truecodes
) 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: