Does PHP have built-in data structures?

后端 未结 14 755
名媛妹妹
名媛妹妹 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:30

    PHP's array doubles as both a list and a dictionary.

    $myArray = array("Apples", "Oranges", "Pears");
    $myScalar = $myArray[0] // == "Apples"
    

    Or to use it as an associative array:

    $myArray = array("a"=>"Apples", "b"=>"Oranges", "c"=>"Pears");
    $myScalar = $myArray["a"] // == "Apples"
    

提交回复
热议问题