I have been getting a syntax error with a multi-dimensional array, and it is driving me nuts.

<?php
$gamedata = array (
  array (
  name => ("Age of Speed 2")
  code => <<<'CODE'
<iframe src="http://www.miniclip.com/games/age-of-speed-2/en/webgame.php" frameborder="0" style="border:none;" width="590" height="443" scrolling="no"></iframe>
CODE
  )
  array (
  name => ("Abbyss Defence")
  code => <<<'CODE'
<a rel="nofollow" href="http://www.freegamesjungle.com/abbyss_defence.html" target="_blank">Abbyss Defence</a>
CODE
  )
  array (
  name => ("Battle Buggy")
  code => <<<'CODE'
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="battlebuggy.swf"><param name="quality" value="high"><embed src="battlebuggy.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
CODE
  )
  array (
  name => ("Airwave")
  code => <<<'CODE'
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="400"><param name="movie" value="airwave.swf"><param name="quality" value="high"><embed src="airwave.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="400"></embed></object>
CODE
  )
  array (
  name => ("The Seeker")
  code => <<<'CODE'
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="500"><param name="movie" value="theseeker.swf"><param name="quality" value="high"><embed src="theseeker.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="500"></embed></object>
CODE
  )
  array (
  name => ("Retro Assault")
  code => <<<'CODE'
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="retroassault.swf"><param name="quality" value="high"><embed src="retroassault.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
CODE
  )
  array (
  name => ("Final Fortress")
  code => <<<'CODE' 
<embed src="finalfortress.swf" type="application/x-shockwave-flash" width="640" height="480"></embed>
CODE
  )
  array (
  name => ("Tank 2008")
  code => <<<'CODE'
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400"><param name="movie" value="tank2.swf"><param name="quality" value="high"><embed src="tank2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>
CODE
  )
  array (
  name => ("Cyborg")
  code => <<<'CODE' 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="650" height="400"><param name="movie" value="Cyborg.swf"><param name="quality" value="high"><embed src="Cyborg.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="400"></embed></object>
CODE
  )
  array (
  name => ("Alien Flight")
  code => <<<'CODE'
<embed src="alienflight.swf" type="application/x-shockwave-flash" width="550" height="420"></embed>
CODE
  )
)
?>

And this is the error message that comes up whenever it's used in an include statement:

Parse error: syntax error, unexpected T_STRING, expecting ')' in C:\Abyss Web Server\htdocs\swf\gamedata.php on line 5

Does anyone have any idea what might be causing this?

      name => ("Retro Assault") 

    You don't need parentheses here, but you do need a comma on the end.

      You have quotes around 'CODE'
      and missing semicolon after the closing CODE

      This is an example of correct heredoc syntax:

      <?php
      
      $str = <<<EOD
      Example of string
      spanning multiple lines
      using heredoc syntax.
      EOD;
      
      ?>

        I tried all that just now and it still does not work.

        This is what it is now, and it pulls up the same error message.

        <?php
        $gamedata = array (
          array (
          name => "Age of Speed 2",
          code => <<<CODE
        <iframe src="http://www.miniclip.com/games/age-of-speed-2/en/webgame.php" frameborder="0" style="border:none;" width="590" height="443" scrolling="no"></iframe>
        CODE;
          )
          array (
          name => "Abbyss Defence",
          code => <<<CODE
        <a rel="nofollow" href="http://www.freegamesjungle.com/abbyss_defence.html" target="_blank">Abbyss Defence</a>
        CODE;
          )
          array (
          name => "Battle Buggy",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="battlebuggy.swf"><param name="quality" value="high"><embed src="battlebuggy.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
        CODE;
          )
          array (
          name => "Airwave",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="400"><param name="movie" value="airwave.swf"><param name="quality" value="high"><embed src="airwave.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="400"></embed></object>
        CODE;
          )
          array (
          name => "The Seeker",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="500"><param name="movie" value="theseeker.swf"><param name="quality" value="high"><embed src="theseeker.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="500"></embed></object>
        CODE;
          )
          array (
          name => "Retro Assault",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="retroassault.swf"><param name="quality" value="high"><embed src="retroassault.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
        CODE;
          )
          array (
          name => "Final Fortress",
          code => <<<CODE
        <embed src="finalfortress.swf" type="application/x-shockwave-flash" width="640" height="480"></embed>
        CODE;
          )
          array (
          name => "Tank 2008",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400"><param name="movie" value="tank2.swf"><param name="quality" value="high"><embed src="tank2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>
        CODE;
          )
          array (
          name => "Cyborg",
          code => <<<CODE
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="650" height="400"><param name="movie" value="Cyborg.swf"><param name="quality" value="high"><embed src="Cyborg.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="400"></embed></object>
        CODE;
          )
          array (
          name => "Alien Flight",
          code => <<<CODE
        <embed src="alienflight.swf" type="application/x-shockwave-flash" width="550" height="420"></embed>
        CODE;
          )
        )
        ?>

          what's wrong with just using single quoted strings?

            but if you must, this works:

            <?php
            $gamedata = array (
              array (
              name => "Age of Speed 2",
              code => <<<CODE
            <iframe src="http://www.miniclip.com/games/age-of-speed-2/en/webgame.php" frameborder="0" style="border:none;" width="590" height="443" scrolling="no"></iframe>
            CODE
              ),
              array (
              name => "Abbyss Defence",
              code => <<<CODE
            <a rel="nofollow" href="http://www.freegamesjungle.com/abbyss_defence.html" target="_blank">Abbyss Defence</a>
            CODE
              ),
              array (
              name => "Battle Buggy",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="battlebuggy.swf"><param name="quality" value="high"><embed src="battlebuggy.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
            CODE
              ),
              array (
              name => "Airwave",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="400"><param name="movie" value="airwave.swf"><param name="quality" value="high"><embed src="airwave.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="400"></embed></object>
            CODE
              ),
              array (
              name => "The Seeker",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="500"><param name="movie" value="theseeker.swf"><param name="quality" value="high"><embed src="theseeker.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="500"></embed></object>
            CODE
              ),
              array (
              name => "Retro Assault",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="480"><param name="movie" value="retroassault.swf"><param name="quality" value="high"><embed src="retroassault.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="480"></embed></object>
            CODE
              ),
              array (
              name => "Final Fortress",
              code => <<<CODE
            <embed src="finalfortress.swf" type="application/x-shockwave-flash" width="640" height="480"></embed>
            CODE
              ),
              array (
              name => "Tank 2008",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400"><param name="movie" value="tank2.swf"><param name="quality" value="high"><embed src="tank2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>
            CODE
              ),
              array (
              name => "Cyborg",
              code => <<<CODE
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="650" height="400"><param name="movie" value="Cyborg.swf"><param name="quality" value="high"><embed src="Cyborg.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="400"></embed></object>
            CODE
              ),
              array (
              name => "Alien Flight",
              code => <<<CODE
            <embed src="alienflight.swf" type="application/x-shockwave-flash" width="550" height="420"></embed>
            CODE
              )
            )
            ?> 
            

              OK, now I see what the problem was. Thank you very much.

                halojoy wrote:

                This is an example of correct heredoc syntax:

                But the code posted is nowdoc syntax, which does use single quotes around the delimiter.

                  halojoy;10937209 wrote:

                  You have quotes around 'CODE'
                  and missing semicolon after the closing CODE

                  And iirc, the terminating semicolon is optional.

                    johanafm wrote:

                    And iirc, the terminating semicolon is optional.

                    In this case it's just wrong, since we're in the middle of initialising an array, not at the end of a statement.

                      if they are static why not just DEFINE them and then use them in the array?

                        Weedpacket;10937232 wrote:

                        But the code posted is nowdoc syntax, which does use single quotes around the delimiter.

                        BTW, just thought I'd mention this: I recently found out that my web host has PHP 5.2.10 and not 5.3.0, which was my (other) problem to begin with.

                          Write a Reply...