2014-12-03 99 views
-1

php代碼顯示意想不到的語法錯誤[行號碼1 我不知道是什麼問題。如果您使用PHP 5.4或更高版本,你可以使用這個語法錯誤:「[」意外

$shipping_array = array(
        "AL" => array("a","c","b"), 
        "AZ" => array("b","c","a"), 
        "AR" => array("a","c","b"), 
        "WI" => array("c","a","b") 
       ); 

$shipping_array = [ "AL" => ["a","c","b"], 
    "AZ" => ["b","c","a"], 
    "AR" => ["a","c","b"], 
    "WI" => ["c","a","b"] ]; 
+7

速記數組聲明是PHP 5.4以上 – Ghost 2014-12-03 08:23:24

回答

3

您使用短陣列聲明,您必須使用PHP 5.4或h igher。

試試這個PHP 5.4下:在你的語法

$shipping_array = array(
    "AL" => array("a","c","b"), 
    "AZ" => array("b","c","a"), 
    "AR" => array("a","c","b"), 
    "WI" => array("c","a","b") 
); 

http://php.net/manual/en/language.types.array.php

-2

問題,你一定要試試這個:

$shipping_array = array("AL" => array("a","c","b"), 
         "AZ" => array("b","c","a"), 
         "AR" => array("a","c","b"), 
          "WI" => array("c","a","b") 
         ); 
+0

語法不問題!這是PHP版本 – Rizier123 2014-12-03 08:30:56