duan19850312 2016-06-17 19:47
浏览 65

PHP关联数组的平等性

Quick question about PHP assosiative arrays.

Say there are two arrays:

$A=array ("AAA"=>"45", "FFF"=>"108", "GGG"=>"15"); 

and

$B=array ("FFF"=>"108", "GGG"=>"15", "AAA"=>"45");

Are these arrays are equal arrays? In the annother words, is the position of entry in assosiative arrays matters?

Merci beaucoup!

  • 写回答

1条回答 默认 最新

  • dongxun6458 2016-06-17 19:52
    关注

    According to PHP official document:

    http://php.net/manual/en/language.operators.array.php

    Equality:

    $a == $b TRUE if $a and $b have the same key/value pairs.

    Identity:

    $a === $b TRUE if $a and $b have the same key/value pairs in the same order and of the same types.

    Demo:

    $A=array ("AAA"=>"45", "FFF"=>"108", "GGG"=>"15");
    $B=array ("FFF"=>"108", "GGG"=>"15", "AAA"=>"45");
    
    var_dump($A==$B);
    

    bool(true)

    var_dump($A===$B);
    

    bool(false)

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献