php explode() function


  Translation results:

英[ɪkˈspləʊd] US[ɪkˈsploʊd]

vi. Explode [suddenly], get angry; surge, expand rapidly

vt. (make) explode; suddenly (make a loud noise, come alive, burst out with emotions); overthrow; refute

Third person singular: explodes Present participle: exploding Past tense: exploded Past participle: exploded

php explode() functionsyntax

Function: Break up the string into an array

Syntax: explode(separator,string,limit)

Parameters:

ParametersDescription
separatorRequired . Specifies where to split the string.
string Required. The string to split.
limitOptional. Specifies the number of array elements to be returned. Possible values: greater than 0 - returns an array containing at most limit elements, less than 0 - returns an array containing all but the last -limit elements, 0 - returns an array containing one element

Instructions: Break up the string into an array. The "separator" parameter cannot be an empty string. This function is binary safe.

php explode() functionexample

<?php
$str = "Hello world. I'm study in php.cn!";
print_r (explode(".",$str));
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [0] => Hello world [1] => I'm study in php [2] => cn! )


<?php
$arr = "Learning PHP is a good choice";
print_r(explode(" ", $arr));
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [0] => Learning [1] => PHP [2] => is [3] => a [4] => good [5] => choice )

Popular Recommendations

Home

Videos

Q&A