简体   繁体   中英

How can i get output array having only different key?

I have following two array

 $array1 = array("product_a" => "Nokia1", "product_b" => "Nokia11", "product_c" => "Nokia111", "Nokia1111"); $array2 = array("product_a" => "Nokia1", "Samsung", "Nokia1111"); 

I want to compare these both array and want output as having different keys

Like my output as below

 Array ( [product_b] => Nokia11 [product_c] => Nokia111 [0] => Nokia1111 ) 

is there any default php method available to compare?

I think that you can try

 function key_compare_func($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } 

You can get some reference with following link too,

http://questionnanswer.com/questions/view_question/80/category_list:2/how-can-get-different-key-array ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM