Friday, October 3, 2025
HomeLanguagesPHP mb_split() Function

PHP mb_split() Function

The mb_split() is an inbuilt PHP function that split the multibyte strings with help of the regular expression.

Syntax:

mb_split(pattern,string,limit): array|false

Parameters:  This function accepts 3 parameters:

  • pattern: In this parameter, we define a regular expression that helps us to split a string.
  • string:  This parameter defines a string that’s going to be split using by pattern parameter.
  • limit: This parameter is an optional parameter. This parameter defines the maximum limit of the split string.

Return value: If this function executes successfully then it will return an array otherwise it will return “false”.

Example 1: The following code demonstrates the mb_split() function.

PHP




<?php
   print_r(mb_split('\s',"Hello neveropen"));
?>


Output:

Array
(
   [0] => Hello
   [1] => neveropen
)
 

Example 2: The following code demonstrates the mb_split() function using a delimiter.

PHP




<?php   
   $string = "The,longest,sentence,in,English,is,also,awesome";
   $characters = mb_split(",", $string);
   print_r($characters);
?>


Output:

Array
(
    [0] => The
    [1] => longest
    [2] => sentence
    [3] => in
    [4] => English
    [5] => is
    [6] => also
    [7] => awesome
)

Reference: https://www.php.net/manual/en/function.mb-split.php

RELATED ARTICLES

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6819 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS