Skip to content

Add default value for length in mb_substr and mb_strcut#133

Closed
Irker wants to merge 1 commit intophp:masterfrom
Irker:null_default_in_mbstring
Closed

Add default value for length in mb_substr and mb_strcut#133
Irker wants to merge 1 commit intophp:masterfrom
Irker:null_default_in_mbstring

Conversation

@Irker
Copy link
Contributor

@Irker Irker commented Jul 17, 2012

In this commit(s) I added "null" default values for length in mb_strcut and mb_substr.
So now we can write:
$result = mb_substr("12345", 2, null, "UTF-8");
And get expected result : "345"

I added this similar to function array_slice (length parametr) php.net/manual/en/function.array-slice.php

I think no great BC there. All exist tests passed.

If you like this idea, I can add tests for my patch.

Yes, I know about mb_internal_encoding.
Yes, I know about discussion about "default" keyword.

@hirokawa
Copy link
Contributor

I think that this patch is valuable, and acceptable.

@lstrojny
Copy link
Contributor

@Irker this fixes a long standing inconvenience, thanks. Could you add a test case?

@php-pulls
Copy link

Comment on behalf of lstrojny at php.net:

Merged to PHP-5.4 and master. Thanks for your contribution!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants