Skip to content

grapheme_extract() returns false instead of empty string when the offset is equal to the length of the haystack #18031

Open
@claudepache

Description

@claudepache

Description

The following code:

<?php
var_dump(grapheme_extract('', 42));
var_dump(grapheme_extract('ab', 42, offset: 2));

Resulted in this output:

bool(false)
bool(false)

But I expected this output instead:

string(0) ""
string(0) ""

Per documentation, the offset ought to be less then or equal to the length of the string (which I consider an appropriate range).

PHP Version

PHP 8.3

Operating System

No response

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