Skip to content

str_split must return empty array for empty string #8924

Description

@mvorisek

Description

The following code:

<?php

print_r(str_split('', 1));
print_r(mb_str_split('', 1));
print_r(mb_str_split('', 1, 'UTF-8'));
print_r(mb_str_split('', 1, 'ASCII'));
print_r(array_chunk([], 1));

https://3v4l.org/1WsGi

Resulted in but I expected this output instead:

 Array
 (
-    [0] => 
 )
 Array
 (
 )
 Array
 (
 )
 Array
 (
 )
 Array
 (
 )

I belive this is an inconsistency that should be fixed.

The inconsistency was introduced in 0818fae by a mistake as found out by @emkey08 in the discussion below.

PHP Version

PHP 7.4 - master

Operating System

any

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions