In PHP, the substr() function is used to extract a portion of a string. The function takes three parameters: the original string, the starting position, and the length of the desired substring.
Here is an example of how to use the substr() function to cut a string:
$str = "Hello, World!";
$cutStr = substr($str, 0, 5); // Extracts "Hello" from the original string
echo $cutStr; // Outputs "Hello"
In this example, the substr() function is used to extract the first 5 characters from the original string and store it in the $cutStr variable. The resulting substring is then echoed to the screen.
上一篇:php=和==
下一篇:php 取得文件大小
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站