Home  >  Article  >  Backend Development  >  How to implement php to intercept the last few digits of a string

How to implement php to intercept the last few digits of a string

藏色散人
藏色散人Original
2020-08-08 09:38:396217browse

php method to intercept the last four digits of a string: first create a PHP sample file; then intercept the last four digits of the specified string through the "substr($str_bh,-4);" method; and finally output it through echo Just intercept the results.

How to implement php to intercept the last few digits of a string

Recommendation: "PHP Video Tutorial"

Example:

After PHP intercepts the string Four digits

$str_bh='123456789';
$abc=substr($str_bh,-4);
echo $abc;

Output result: 6789

<?php
echo substr("Hello world!",6,5);
?>

Result: world

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

Statement:
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 admin@php.cn