Questions about the Array_diff function

Source: Internet
Author: User
I use Array_diff comparison to read the TXT file title and I set the same, where the last field is always determined to be different, the surface of the last field more than a space, I added a space, also decided not the same, what method I use to see the TXT file the last field of the content is what??


Reply to discussion (solution)

Give me a hand. Txt?? Base64, and see if it's the same.

Can you paste out your code???

Need to see your code and test data

Private Function Checkfiletype ($array) {$type = "";         foreach ($this->filetypearray as $name = + $value) {$ar =array_diff ($array, $value);        if (empty ($ar)) {$type = $name;  }} return $type; }private $filetypearray =array (' DownloadFile ' =>array (' Order-id ', ' Order-item-id ', ' purchase- Date ', ' payments-date ', ' buyer-email ', ' buyer-name ', ' buyer-phone-number ', ' s Ku ', ' product-name ', ' quantity-purchased ', ' currency ', ' item-price ', ' Item-ta                                                  X ', ' Shipping-price ', ' shipping-tax ', ' ship-service-level ', ' recipient-name ', ' ship-address-1 ',                                                  ' Ship-address-2 ', ' ship-address-3 ', ' ship-city ', ' ship-state ', ' ship-postal-code ', ' ship-country ', ' Ship-phone-number ', ' delivery-start-date ', ' delivery-end-date ', ' Delivery-time-zone ', "Delivery-instructions")); $order[']= ' ('. Base64_encode ($more [28]) ') '; $order [']= ' (' Base64_encode ' ($this->filetypearray[' DownloadFile '][28]) '; [zgvsaxzlcnktsw5zdhj1y3rpb25zdq==] [+] = (zgvsaxzlcnktsw5zdhj1y3rpb25zia==)

Base64 results for two fields, the last part is different

What's that dq==? I do not add space code is zgvsaxzlcnktsw5zdhj1y3rpb25z

Base64 encoded by:
dq== is a carriage return 0x0d (Chr (13))
ia== is a space character 0x20 (Chr (32))

In general, the end-to-end whitespace characters are negligible, so it is advisable to trim
$ar = Array_diff (Array_map (' trim ', $array), Array_map (' trim ', $value));

  • 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.