Does PHP have built-in data structures?

后端 未结 14 725
名媛妹妹
名媛妹妹 2021-01-30 00:18

I\'m looking at the PHP Manual, and I\'m not seeing a section on data structures that most languages have, such as lists and sets. Am I just blind or does PHP not have anything

相关标签:
14条回答
  • 2021-01-30 00:51

    For the Compulsory need of data structures please browse for the SPL(PHP Extensions). They are having data structures like heap,linked-list,.. etc...

    PHP not having the list and set data structures exactly. but they can achieved by array(with n Dimentions), that provide the multiple data with single cluster

    $variable = array(
      'one' => array(1,'char',3),
      'two' => explode("single", "Multiple strings"),
      'three' => all(9,'nine',"nine")
    );
    

    They are not exactly as list or set. But array can replace that. So no need to search for another data structures.

    0 讨论(0)
  • 2021-01-30 00:52

    As for today (PHP 7.4), only native structure is an array. But from PHP7 extension DS appeared that includes new data structures and all of them are much faster than other implementations (including SPL recommended in accepted answer).

    DS extension - PHP Manual

    Interfaces: Collection, Hashable, Sequence

    Classes: Vector, Deque, Map, Pair, Set, Stack, Queue, PriorityQueue

    Orginal article about extension

    0 讨论(0)
提交回复
热议问题