如果我有一个数组 $arr = array('aaa', 'bbb', 'ccc'), 我join("|", $arr)后得到的一定是“aaa|bbb|ccc”吗?
explode同样。产生这个问题是因为我要根据join()后的字符串做md5,如果顺序不一样得到的md5就不一样了,
我记得php的关联数组也就是哈希,是不关注顺序的,不知道普通数组也是如此。没想到什么好的测试验证的方法,
希望有经验的网友给予解答或验证方法。

解决方案 »

  1.   

    string implode ( string $glue , array $pieces )
    string implode ( array $pieces )
    Returns a string containing a string representation of all the array elements in the same order, 
    with the glue string between each element. 
      

  2.   

    Returns a string containing a string representation of all the array elements in the same order,
    with the glue string between each element. 
      

  3.   

    不会改变顺序,PHP所有数组本质上都是关联数组
      

  4.   

    不会改变,要理解数组的两种方式,一种种是哈希,一种是数值链
    比如mysql_fetch_array 返回的数组就有两个键,虽然有哈希的,但它们都有数值键位
      

  5.   

    php数组有两种插入方式,
    key为整数:zend_hash_index_update
    key为字符串:zend_hash_update虽然有两种形式,但是本质都是hash,hash可以看作是长度为N的C语言数组,
    若下标是字符串,则用times33 hash算法生成整数,用这个整数作为内部hash中数组的下标,
    若下标是可转换为合格整数的字符,则直接用这个整数作为内部hash中数组的下标,
    两种方式可以混用,也可以单独使用,mysql_fetch_array()就同时出现了这两种方式的使用。纯整数下标,直接定位,而且不会冲突,因此性能很高
    字符串下标,有冲突可能性,加上zend_hash算法的开销,性能大打折扣