用php替换范围[重复]

This question already has an answer here:

I am trying to replace first 2000 characters of a string with null.

For example:

$content = "nvinveneuifnoimmio";
$my_result = "fnoimmio";

I mean that I want the first 10 characters to be removed or to be replaced with a space character in above example.

whats the easiest way to do it?

thanks

</div>

Use substr()

$my_result = ' ' . substr($content, 10);

substr is what you need. It will take a section of the given string, x characters from the start.

$content = "nvinveneuifnoimmio";
$my_result = substr($content, 10);

If you want to replace instead, you can use a combination of substr_replace and maybe str_repeat:

$content = "nvinveneuifnoimmio";
$characters = 10;
$my_result = substr_replace($content, str_repeat(' ', $characters), 0, $characters);