Question about the array_diff function

Source: Internet
Author: User
About the array_diff function, I used array_diff to compare whether the title of the txt file read is the same as what I set. The last field is always determined to be different, on the surface, a space is added to the last field, and the difference is also determined. how can I view the content of the last field in the txt file ??


Reply to discussion (solution)

Put ?? Txt ?? Base64, and then check whether it is the same.

Can I paste your code ???

You 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','sku','product-name','quantity-purchased','currency','item-price',                                                  'item-tax','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['28']='('.base64_encode($more[28]).')'; $order['29']='('.base64_encode($this->filetypearray['downloadfile'][28]).')';[28] => (ZGVsaXZlcnktSW5zdHJ1Y3Rpb25zDQ==)[29] => (ZGVsaXZlcnktSW5zdHJ1Y3Rpb25zIA==)

The base64 result of the two fields. The last part is different.

What is that DQ = ?? ZGVsaXZlcnktSW5zdHJ1Y3Rpb25z without space encoding

Base64 encoded:
DQ = is the carriage return character 0x0d (chr (13 ))
IA = is a space character 0x20 (chr (32 ))

Generally, the leading and trailing spaces can be ignored.
$ 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.