phpset

Does PHP have a Set data structure?


I'm new to PHP, and I can't figure out this basic question. Does PHP have some sort of set or list object? Something like an array, but with the ability to dynamically add or remove any number of objects from it.


Solution

  • Yes, you could use the array object and the array functions.

    Basically, you could dynamically grow an array using the array_push function, or the $arrayName[] = ... notation (where arrayName is the name of your array).