How to intercept the first few digits of data in php

hzc
Release: 2023-03-01 13:34:02
Original
3635 people have browsed it

How to intercept the first few digits of data in php

The method for php to intercept the first few digits of data is:

Copy after login
Copy after login
Copy after login
Copy after login
// 访问字符串中的单个字符
// 也可以使用中括号
$string = 'abcdef';
echo $string[0];                 // a
echo $string[3];                 // d
echo $string[strlen($string)-1]; // f
?>
Copy after login
中文字符串的截取和获取长度 mb_substr()
$str = '我abc是谁';  //utf-8编码的字符串
echo mb_substr($str, 0, 2, 'utf-8'); //输出 我a
Copy after login
$str = '我是谁';  //gbk编码的字符串
echo mb_substr($str, 0, 1, 'gbk'); //输出 我
Copy after login

Recommended tutorial: "php tutorial"

The above is the detailed content of How to intercept the first few digits of data in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!