In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "php how to read a few characters after the string", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "php how to read a few characters after the string"!
In php, you can use the substr() function to read the last few characters of a string by setting the second argument of the function to a negative value and omitting the third argument; the syntax is "substr(string,-n)", which means reading all characters from the end of the string to the nth character.
Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer
In php, you can use the substr() function to read the last few characters of a string.
The substr() function returns a portion of a string.
Simply omit the third argument to the function and set the second argument to a negative value (-n), n specifying the next few characters you want to read
Implementation example:
Description:
The substr() function intercepts a certain length of characters from a specified position in a string. This truncated character can be called a "substring" or a "substring". Its syntax is as follows:
substr($string, $start [, $length])
Parameters are described as follows:
$string: string to be truncated, the string contains at least one character;
$start: the starting position of the truncated string;
If $start is non-negative, then the string will be truncated starting at the $start character of $string, and $start will be evaluated starting at 0. For example, in the character string "abcdef," the character at position 0 is "a," the character string at position 2 is "c," and so on;
If $start is negative, then the string starts at the $start character counting forward from the end of $string, and $start starts at-1. For example, in the string "abcdef," the character at position-1 is "f," the character at position-3 is "d," and so on;
If the length of $string is less than $start, FALSE is returned.
$length: Optional parameter indicating the length of the truncated string.
If $length is positive, the string will be truncated up to $length characters backward from the $start position;
If $length is negative, then the $length characters at the end of $string will be omitted (starting from the end of the string if $start is negative);
If the value of $length is 0, FALSE, or NULL, an empty string is returned;
If $length is not provided, the returned substring starts at the $start position and continues to the end of the string.
At this point, I believe that we have a deeper understanding of "how php reads a few characters after a string," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.