Leave one character in the php rule

Source: Internet
Author: User
Leave a $ a & nbsp; in php to exclude the same character. Hello, hello, he is good, he is good, I am good, I am good, he is good, I am good; how can I separate "," in "$ a" and remove the same ones from it? a big brother who is troublesome to know can directly give the complete code to you. hello, he is good, I am good, hi, he is. I just want to exclude one of the same php characters in green and red.
$ A = "'Hello', 'hello ', 'Hi me '";


In $ a, how does one exclude the same

Easy to understand, Big Brother, directly give the complete code

'Hi, 'hi,', 'Hi'

It is to take one of the green and red parts. sometimes three, four, and five are the same, but all of them are the same.
'Hello', 'Hello, ', 'hello ', 'Hi! ', 'Hi!', 'Hi'

Share: More


------ Solution --------------------
$ B = join (',', array_unique (explode (",", $ )));

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.