How to get the number of string in php

王林
Release: 2023-03-10 21:18:01
Original
2317 people have browsed it

The way PHP retrieves the number of a string is to pass the string as a parameter to the substr function, and set the starting point and the length of the string to be returned, for example [substr("Hello world", 6)].

How to get the number of string in php

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

php has a very rich function library, including a function substr(), which can take out any part of the string. Returns FALSE on failure, or an empty string.

Syntax:

substr(string,start,length)
Copy after login

Parameters:

  • string Required. Specifies a part of the string to be returned.

  • #start Required. Specifies where in the string to begin.

  • #length Optional. Specifies the length of the string to be returned. The default is until the end of the string.

Code example:

     
Copy after login

Running result:

world
Copy after login

Related video sharing:php video tutorial

The above is the detailed content of How to get the number of string in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 admin@php.cn
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!