Home >Backend Development >PHP Tutorial >Questions about appending data in PHP
Example:
<code>$a = "1,3,4"; </code>
How to append data to $a? Before appending, you need to check whether it contains the pre-added number. For example, 5 is not among them, then the result after appending is:
<code>$a = "1,3,4,5"; </code>
How to achieve this?
Example:
<code>$a = "1,3,4"; </code>
How to append data to $a? Before appending, you need to check whether it contains the pre-added number. For example, 5 is not among them, then the result after appending is:
<code>$a = "1,3,4,5"; </code>
How to achieve this?
<code>implode(',',array_unique(explode(',',$a)))</code>
Convert to array first, merge, remove duplicates, then convert back
Why not use an array? array_search() checks whether the memory exists. If it does not exist, push it to enter. Finally, impload(l