In PHP development, it is often necessary to intercept and filter strings to meet different needs. This article will introduce some common techniques and methods to help you better handle strings. Below is some sample code to help you understand and apply these techniques.
Character interception
1. Use substr function to intercept string
$str = "Hello, World!";
$substring = substr($str, 0, 5);
echo $substring