意外的T_DOUBLE_ARROW

时间:2011-07-13 06:30:29

标签: php arrays

嗨我在第13行遇到意外的T_DOUBLE_ARROW。我知道它看起来像是一个非常复杂的数组,但它需要你是这样的。之后可能还会有更多错误。请有人解释我的错误。感谢

<?php

$LibraryStatus = true;
$ControlStatus = true;
$HDDStatus = true;

$arrLayout = array(

         "section1" => array(

         ($LibraryStatus ? array("wLibrary" => array("title"   => "Library",
                                                     "display" => "")) : false),
        ($ControlStatus ? ("wControl" => array("title"   => "Control",
                                                     "display" => "")) : false)),

        "section2" => array(

        ($HDDStatus ? array("whdd" => array("title" => "HDD",
                                            "display" => "")) : false)));
?>

2 个答案:

答案 0 :(得分:8)

此处缺少array

($ControlStatus ? ("wControl" => ...

应该是:

($ControlStatus ? array("wControl" =>...

答案 1 :(得分:2)

你的一个条件中缺少“数组”:

<?php

$LibraryStatus = true;
$ControlStatus = true;
$HDDStatus = true;

$arrLayout = array(
  "section1" => array(
    ( $LibraryStatus ?
      array(
        "wLibrary" => array(
          "title"   => "Library" ,
          "display" => ""
        )
      ) :
      false ) ,
    ( $ControlStatus ?
      array( /* This was the missing "array" */
        "wControl" => array(
          "title"   => "Control" ,
          "display" => ""
        )
      ) :
      false )
  ) ,
  "section2" => array(
    ( $HDDStatus ?
      array(
        "whdd" => array(
          "title" => "HDD" ,
          "display" => ""
        )
      ) :
      false )
  )
);
?>