ArrayList的在PHP [英] ArrayList in php

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

问题描述

是否有 PHP中的任何数据结构阵列等。是否有可能创建一个数据结构,如的ArrayList ?如果有,请提供一些参考或某种形式实现。

Are there any data structures in php other than array. Is it possible to create a data structure such as an ArrayList? If so please provide some references or some kind of implementation.

推荐答案

您需要了解的一切阵列可以在的 文档

Everything you need to know about arrays can be found in the documentation.

所有的数组的可用功能在 函数参考

All of the available functions for arrays are listed in the functions reference.

一些注意事项:

在下面我试着列出PHP替代品最常见的<一个href=\"http://download.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html\"><$c$c>ArrayList方法的:

In the following I tried to list the PHP alternatives for the most common ArrayList methods:


  • 添加(元素)基本上是通过追加$数组[] = $元素。新价值获取下一个免费的数字索引(这是preferred方式)。您也可以使用 array_push($数组$元素)

  • 的addAll(ArrayList的) array_merge($数组1,$数组2) 的方式。合并关联数组时要小心。对于相同的密钥值将被覆盖。

  • 的clone():由于数组是不是对象,你克隆,只需将其分配给另一个变量数组:

  • add(element) is basically just appending via $array[] = $element. The new value gets the next free numeric index (this is the preferred way). You can also use array_push($array, $element).
  • addAll(ArrayList): array_merge($array1, $array2) in a way. Be careful when merging associative arrays. Values for the same keys will be overwritten.
  • clone(): As arrays are not objects, you "clone" an array by just assigning it to another variable:

    $a = array(1,2,3);
    $b = $a;


  • 包含(元素) in_array($元,$阵列)

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

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