Your Open Source

 
Related Posts
PHP  >>  String

Explode Function in PHP

The explode() function is used to break a string into an array.

Syntax is: explode(separator,string,limit)

The first parameter is the separator, this is required, it specifies where to break the string. The second parameter is the given string, of course, this is required. The third is the limit, this is optional, it specifies the maximum number of array elements to return.

Example:

<?php

$str = "PHP is fun!.";
print_r (explode(" ",$str));
?>

Output is:

Array
(
[0] => PHP
[1] => is
[2] => fun!.
)

Another example, this time with the third parameter:

<?php

$str = "PHP is fun!."

print_r(explode(" ", $str, 2));
?>

Output is:

Array
(
[0] => PHP
[1] => is
)

  • hits 113
  • datetime Aug 01 09 01:32:56
  • author Lazywriter
  • rating

Rating : 12345
Tags :- String

Answers

No Answers..
Your Name:
Your Answers :
<> is a code tag
Preview
Enter the verification code: