``` --- ## Definition"> ``` --- ## Definition" />
Easy Tutorial
❮ Php Post Filter Validate Booleant ❯

PHP explode() Function

PHP String Reference Manual

Example

Split a string into an array:

<?php
$str = "www.tutorialpro.org";
print_r (explode(".",$str));
?>

Definition and Usage

The explode() function splits a string by another string and returns an array of strings.

Note: The "separator" parameter cannot be an empty string.

Note: This function is binary-safe.


Syntax

Parameter Description
separator Required. Specifies where to split the string.
string Required. The string to split.
limit Optional. Specifies the number of array elements to return. Possible values: greater than 0 - returns an array with a maximum of limit elements<br> less than 0 - returns an array excluding the last -limit elements<br> 0 - is treated as 1, returns an array with one element

Technical Details

Return Value: Returns an array of strings.
PHP Version: 4+
--- ---
Changelog: Added the limit parameter in PHP 4.0.1. Added support for negative limits in PHP 5.1.0.
--- ---

More Examples

Example 1

Use the limit parameter to return some array elements:

<?php
$str = 'one,two,three,four';

// Return an array with one element
print_r(explode(',',$str,0));
print "<br>";

// Array elements: 2
print_r(explode(',',$str,2));
print "<br>";

// Remove the last array element
print_r(explode(',',$str,-1));
?>

❮ Php Post Filter Validate Booleant ❯