Home  >  Article  >  Backend Development  >  How to intercept the last four digits of a string in PHP

How to intercept the last four digits of a string in PHP

小云云
小云云Original
2018-03-27 09:50:1837921browse

Sometimes we will encounter the problem of displaying the following digits of a string. How to implement this function?

This article mainly shares with you how to intercept the last four digits of a string in PHP. I hope it can help you.

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

Output result: 6789

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

Result: world

Recommended related articles:
1.How to intercept strings in php The last few
2.How to get the last n characters of a PHP string
Related video recommendations:
1.Dugu Jiujian (4)_PHP video tutorial

Related recommendations:

A collection of common methods for intercepting strings in JS

How to implement the function of intercepting strings in js

Introduction to the method of intercepting strings in php

The above is the detailed content of How to intercept the last four digits of a string in PHP. 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