[英]check the same value on different arrays or variables
I have 2 variables of equal value: 我有两个相等的变量:
$word1 = 'a, b, c, d';
$word2 = 'b, c, d, a';
I want to check whether the two variables have exactly the same value. 我想检查两个变量是否具有完全相同的值。 How to check it?
怎么检查?
You could use array_dif() 你可以使用array_dif()
Example 例
<?php
$word1 = 'a, b, c, d';
$word2 = 'b, c, d, a';
$array1 = explode(', ', $word1);
$array2 = explode(', ', $word2);
$result = array_diff($array1, $array2);
print_r($result);
?>
using this code you have to get same value in array 使用此代码,您必须在数组中获得相同的值
<?php
$word1 =array('a, b, c, d');
$word2 =array('b, c, d, a');
$data = array_intersect($word1, $word2);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.