PHP数组运算符[重复]

This question already has an answer here:

I’m now learning PHP array but I have a question about the array operator. I saw an example when creating an array like this:

<?php
$array = array();
$array["a"] = "apple";
$array["b"] = "banana";
?>

Do I really need to declare the variable as array first?
Or can I just ignore the first line: $array = array();?

</div>

Better yet, just initialize your array and assign values to it at the same time:

<?php
    $array = array(
        "a" => "apple",
        "b" => "banana"
    );
?>

You don't need to initialize your arrays in PHP. In other words, you don't need $array = array();, but it will save you code to do it like @John Conde showed.