Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:41:57+00:00 2026-06-16T03:41:57+00:00

With substr() you can omit the third parameter to get the whole rest of

  • 0

With substr() you can omit the third parameter to get the whole rest of the string:

substr('abcdefg', 2) // returns "cdefg"

You can’t do the same with mb_substr():

mb_substr('abcdefg', 2, null, 'UTF-8'); // returns empty string

I only found weird and ugly solutions.

  • Setting a very high number as length:

    $a = mb_substr('abcdefg', 2, 9999999999, 'UTF-8');

  • Calculating the number:

    $a = mb_substr('abcdefg', 2, mb_strlen('abcdefg', 'UTF-8') - 2, 'UTF-8');

  • Omitting the charset parameter by using mb_internal_encoding():

    $temp = mb_internal_encoding(); // prevent action at a distance
    mb_internal_encoding('UTF-8');
    $a = mb_substr('abcdefg', 2);
    mb_internal_encoding($temp);

Isn’t there a real solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:41:59+00:00Added an answer on June 16, 2026 at 3:41 am

    Change log shows this as a bug fix in Version 5.4.8 (18-October-2012).

    http://us.php.net/ChangeLog-5.php

    Allow passing null as a default value to mb_substr() and mb_strcut().
    Patch by Alexander Moskaliov via GitHub PR #133.

    Here is a link to the pull request thread also: https://github.com/php/php-src/pull/133

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

id = '01d0'; document.write('<br/>'+id.substr(0,-2)); How can I take a string like '01d0 and get
/^[^\s]+\s([^\s]+)\s/ In PHP,I can use regex to get the substr by $1 , how
How can i substr 20 chars from $xbio and get only complete words? $xbio
How can I use a regular expression in the substr() PHP function to get
In PHP I remember I can do something like substr(string,start,length) now I declare int
I am struggling with the code from few days can anyone help std::string str=uri_req1.substr(found+1);
How can I remove all GET variables from a string apart from ?v= E.g:
Solution: strpos turned out to be the most efficient. Can be done with substr
i am using substr to trim the first 100 characters from the string. however
I want to create a substr method in C++ in a string class that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.