PHP定義數(shù)組并賦值有以下幾種方法:
$fruits = array("apple", "banana", "orange");
$fruits = ["apple", "banana", "orange"];
$fruits = array("a" => "apple", "b" => "banana", "o" => "orange");
或
$fruits = ["a" => "apple", "b" => "banana", "o" => "orange"];
$fruits = array();
$fruits[0] = "apple";
$fruits[1] = "banana";
$fruits[2] = "orange";
或
$fruits = [];
$fruits[0] = "apple";
$fruits[1] = "banana";
$fruits[2] = "orange";
以上是一些常見的定義數(shù)組并賦值的方法。根據(jù)不同的需求和場景,可以選擇適合的方法來定義和賦值數(shù)組。