PHP比较阵列 [英] PHP compare array

查看:99
本文介绍了PHP比较阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是有使用一个内置的函数在PHP中比较数组,总之做一些循环的?

  $ A1 =阵列(1,2,3);
$ A2 =阵列(1,2,3);如果(array_are_same($ A1,$ A2)){
    // code在这里
}

顺便说一下,数组值并不总是以相同的顺序


解决方案

 如果($ A == $ B){
    回应我们都是一样的!
}

Is there anyway to compare arrays in php using an inbuilt function, short of doing some sort of loop?

$a1 = array(1,2,3);
$a2 = array(1,2,3);

if (array_are_same($a1, $a2)) {
    // code here
}

Btw, the array values will not always be in the same order.

解决方案

if ( $a == $b ) {
    echo 'We are the same!'
}

这篇关于PHP比较阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆