PHP定义数组并赋值有以下几种方法:
$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";
以上是一些常见的定义数组并赋值的方法。根据不同的需求和场景,可以选择适合的方法来定义和赋值数组。