Home  >  Article  >  Backend Development  >  9 PHP string functions

9 PHP string functions

WBOY
WBOYOriginal
2016-08-08 09:19:59895browse

PHP strlen() function

strlen() function returns the length of a string, in characters.

<code><span><span><?php</span><span>echo</span> strlen(<span>"Hello world!"</span>);
<span>?></span></span>
输出:12</code>

PHP strpos() function

strpos() function is used to retrieve specified characters or text within a string.

If a match is found, the first matching character position is returned. If no match is found, FALSE will be returned.

<code><span><span><?php</span><span>echo</span> strpos(<span>"Hello world!"</span>,<span>"world"</span>);
<span>?></span></span></code>

The output of the above code is: 6.

Tips: The position of the string "world" in the above example is 6. The reason for 6 (rather than 7) is that the first character in the string is at position 0 instead of 1.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced 9 PHP string functions, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Previous article:Linux-nginx-base1Next article:Linux-nginx-base1