In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how php removes the content after a specified location". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope that this article "how to remove the content after a specified location in php" can help you solve the problem.
Removal method: 1, using the "substr_replace ($str,'', position value)" statement, you can replace all the characters after the specified position of the string with empty characters, and then remove all characters; 2, using the "array_splice ($arr, position value)" statement, you can remove all elements after the specified position of the array.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php implements two ways to remove the content after the specified location is removed:
Use the substr_replace () function
Use the array_splice () function
1. Substr_replace () function
Use substr_replace () to remove all characters after the specified position of the string (just set the replacement value to an empty character)
2. Array_splice () function
Using array_splice (), you can remove all elements after the specified position in the array.
Example: there is such an array:
The contents after deleting the first element of the array
Echo "content after deleting the first element of the array:"; array_splice ($arr,1); var_dump ($arr)
The contents after deleting the second element of the array
Echo "content after deleting the second element of the array:"; array_splice ($arr,2); var_dump ($arr)
The contents after deleting the third element of the array
Echo "content after deleting the third element of the array:"; array_splice ($arr,3); var_dump ($arr)
The contents after deleting the fourth element of the array
Echo "content after deleting the fourth element of the array:"; array_splice ($arr,4); var_dump ($arr)
This is the end of the content about "how php removes the content after the specified location". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.