php method to delete character prefixes: first create a PHP sample file; then define a string; finally remove the specified prefix characters through the "substr($arr1,4);" method.
Recommended: "PHP Video Tutorial"
The function that comes with the system You can achieve this effect in two ways:
$arr1=substr($arr1,4);//去除前4个字符
<meta charset="utf-8" /> <?php $a1="206,206,206,201,206,201"; //$array = explode(',', $a1); //字符串组成数组 $array1=implode(",",array_unique(explode(',', $a1))); print_r($array1); ?>
<?php $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse"); print_r(array_values($a)); // 输出: // Array ( [0] => Cat [1] => Dog [2] => Horse ) ?>
Intercept and remove the first character
<?php $a = "About us"; $a = substr($a,1); echo $a; ?>
substr( $str, 0, 1 );
<?php echo substr("Hello world",0,10)."<br>"; echo substr("Hello world",1,8)."<br>"; echo substr("Hello world",0,5)."<br>"; echo substr("Hello world",6,6)."<br>"; echo substr("Hello world",0,-1)."<br>"; echo substr("Hello world",-10,-2)."<br>"; echo substr("Hello world",0,-6)."<br>"; echo substr("Hello world",-2-3)."<br>"; ?>
Result:
Hello worl
ello wor
Hello
world
Hello worl
ello wor
Hello
world
Quote: http://www.w3school.com.cn/tiy/s.asp?f=demo_php_func_string_substr_2
1 to 4, which is to delete the last four digits
Note: The first letter of length: "l" must be lowercase , "L" is wrong (Length)
The above is the detailed content of How to remove character prefix in php. For more information, please follow other related articles on the PHP Chinese website!