Home  >  Article  >  Backend Development  >  PHP implements method of querying different elements in two arrays_php tips

PHP implements method of querying different elements in two arrays_php tips

WBOY
WBOYOriginal
2016-05-16 19:58:121582browse

The example in this article describes the method of querying different elements in two arrays in PHP. Share it with everyone for your reference, the details are as follows:

<&#63;php
  $a = array(
  "max_allow_dialogs",
  "livechat_server_ip",
  "livechat_service_time",
  "abort_zh_cn",
  "abort_zh_tw",
  "abort_en_usa",
  "welcome_zh_cn",
  "welcome_zh_tw",
  "welcome_en_usa",
  "timeout_zh_cn",
  "timeout_zh_tw",
  "timeout_en_usa",
  "absence_zh_cn",
  "absence_zh_tw",
  "absence_en_usa"
  );
  $b = array(
  "max_allow_dialogs",
  "livechat_server_ip",
  "livechat_service_time",
  "abort_zh_cn",
  "abort_zh_tw",
  "abort_en_usa",
  "welcome_zh_cn",
  "welcome_zh_tw",
  "welcome_en_usa",
  "timeout_zh_cn",
  "timeout_zh_tw",
  "timeout_en_usa",
  );
  $c = array_merge(array_diff($a,$b),array_diff($b,$a));
  print_r($c);
&#63;>

Result:

Array
(
  [0] => absence_zh_cn
  [1] => absence_zh_tw
  [2] => absence_en_usa
)

Readers who are interested in more PHP-related content can check out the special topics of this site: "PHP Object-Oriented Programming Introductory Tutorial", "Summary of PHP String Usage ", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn