In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to solve the problem of insufficient php length". In daily operation, I believe many people have doubts about how to solve the problem of insufficient php length. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how to solve the problem of insufficient php length"! Next, please follow the small series to learn together!
Solution to insufficient php length: 1, create a PHP sample file;2, through the "str_pad($value,2,0,STR_PAD_LEFT);" way to achieve string fixed length is not enough to supplement other strings.
Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer
How to solve PHP length problem?
PHP string fixed length, not enough to complement other strings
// str_pad(string with padding, length after padding, padding string, padding position) $result=["7","6","8","4","3","23","27","9","5","19","10","21"]; if($result){ foreach ($result as $key => $value){ $result[$key]=str_pad($value,2,0,STR_PAD_LEFT); } //$result =["07","06","08","04","03","23","27","09","05","19","10","21"]
Related Introduction:
The str_pad() function fills the string with a new length.
syntax
str_pad(string,length,pad_string,pad_type)
parameters
string Required. Specifies the string to fill. Length is required. Specify the new string length. If the value is less than the original length of the string, nothing is done. pad_string Optional. Specifies the string to be used for padding. The default is blank. pad_type
Optional. Specifies which side of the padding string.
Possible values:
STR_PAD_BOTH -Fill both sides of the string. If not even, the right side gets extra padding. STR_PAD_LEFT -Left side of padded string. STR_PAD_RIGHT -The right side of the padded string. Default. At this point, the study on "how to solve the problem of insufficient php length" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.