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 ));