You could use the substr
function to return a substring starting from the 5th character:
$str = "The quick brown fox jumps over the lazy dog."
$str2 = substr($str, 4); // "quick brown fox jumps over the lazy dog."
You can use this by php function with substr function
<?php
function removeChar($value) {
$value2 = substr($value, 4);
return $value2;
}
echo removeChar("Dummy Text. Sample Text.");
?>
You get this result: " y Text. Sample Text. "
function String2Stars($string='',$first=0,$last=0,$rep='*'){
$begin = substr($string,0,$first);
$middle = str_repeat($rep,strlen(substr($string,$first,$last)));
$end = substr($string,$last);
$stars = $begin.$middle.$end;
return $stars;
}
example
$string = 'abcdefghijklmnopqrstuvwxyz';
echo String2Stars($string,5,-5); // abcde****************vwxyz
If you’re using a multi-byte character encoding and do not just want to remove the first four bytes like substr
does, use the multi-byte counterpart mb_substr
. This does of course will also work with single-byte strings.
$num = "+918883967576";
$str = substr($num, 3);
echo $str;
Output:8883967576
You could use the substr
function please check following example,
$string1 = "tarunmodi";
$first4 = substr($string1, 4);
echo $first4;
Output: nmodi
Source: Stackoverflow.com