How to remove extra commas from php
Most people don't understand the knowledge points of this article "how to remove redundant commas in php", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "how to remove redundant commas in php".
Php to remove extra commas: 1, by "trim($arr1,',')" to remove the first comma;2, by "rtrim($arr1,',')" to remove the tail comma;3, by "ltrim($arr1,',')" to remove the first comma.
Operating environment: Windows 7 system, PHP 7.1 version, DELL G3 computer
How does PHP remove redundant commas?
Remove commas after concatenation strings in php
When using some string concatenation, there will always be a comma at the end. Before, we used the method to judge and remove commas, but it was troublesome. Later, we found a very simple method to use trim to remove commas.
$arr1 = trim($arr1,','); //remove the leading comma $arr1 = rtrim($arr1,','); //remove trailing comma $arr1 = ltrim($arr1,','); //Remove the first comma echo $arr1; The above is about "php how to remove redundant commas" This article content, I believe everyone has a certain understanding, I hope the content shared by Xiaobian is helpful to everyone, if you want to know more related knowledge content, please pay attention to the industry information channel.