Common syntax formats:foreach ($arr as $key = = $value) {$arr _str = $arr [' x_id ']. ‘,‘ . $arr _str;}Assume that the characters in the character array $arr areArr[0] = ' a ';Arr[1] = ' B ';ARR[2] = ' C ';Then, after the concatenation of the $arr
Php removes the usage of the last character substr () of the string. In today's project, remove the last character in the string from the original string 1, 2, 3, 4, 5, and 6. The final result is 1, 2, 3, 4, 5, and 6. the code is as follows: $ str
First, the preface
select()when you read a one-to-many amount of information from a database, you often need to split the retrieved array into a specific character and then concatenate it into a string.
Common syntax formats:
foreach
In today's project, we used to remove the last character in the string, so we used substr. we sorted it out to help you learn it. Used in today's project to remove the last character in the string
Original String 1, 2, 3, 4, 5, 6,
Remove the last
Used in today's project to remove the last character in a string
The original string 1,2,3,4,5,6,
Remove the last character "," and the end result is 1,2,3,4,5,6
The code is as follows:
Copy the Code code as follows:
$str = "1,2,3,4,5,6,";$newstr =
Php deletes the code of the program with the last character of the string. This is the simplest php getting started tutorial. we only need to know a few common functions to delete the last character of the string, such as substr and rtrim. The
Use substr () to remove the last character of the string
"," Must be used to separate the data in the statistical chart. However, when I use a loop to accumulate strings, it is inevitable that there will be one more ",". For example,
Used in today's project to remove the last character in the stringOriginal string 1, 2, 3, 4, 5, 6,Remove the last character "," and the final result is 1, 2, 3, 4, 5, 6.The Code is as follows:Copy codeThe Code is as follows:$ Str = "1, 2, 3, 4, 5, 6
Used in today's project to remove the last character in a string
The original string 1,2,3,4,5,6,
Remove the last character "," and the end result is 1,2,3,4,5,6
The code is as follows:
The code is as follows:
$str = "1,2,3,4,5,6,";
$newstr =
Normal string:
Original string: 1,2,3,4,5,6,
This string: 1,2,3,4,5,6, toward the last character of the Lost ","
Remove the last character "," and the end result is 1,2,3,4,5,6
$str = "1,2,3,4,5,6,"; $newstr = substr ($str, 0,strlen ($STR)-1);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.