php – explode

<?php
$str = ‘one|two|three|four’;
print_r(explode(‘|’, $str, 2));
print_r(explode(‘|’, $str, -1));
?>

explode

This function returns an array of string.

Array
 [0] => one
 [1] => two|three|four
In the above array the string is splited at the second position.
Array
[0] => one
[1] => two
[2] => three
In this array, as their is negative limit used in the coding,
all components except the last limit are returned

Advertisements

3 Comments »

  1. nani said

    goooooood

  2. balaji said

    thats good example

  3. ramesh said

    very good concepts

RSS feed for comments on this post · TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: