-1

I'm trying that my code will output like this with the pre tag:

enter image description here

but he give me an error:

Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ')' in D:\xampp\htdocs\basics\echo.php on line 25

And this is the code:

<?php

    $levels = array(
        1 => array( 'name' => 'level 1', 'desc' => 'This is the first level' ),
        2 => array('name' => 'level 2', 'desc' => 'youve made it to level 2!',
        3 => array('name' => 'level 3', 'desc' => 'The last level'
      )

but its not working.

TimWolla
  • 31,849
  • 8
  • 63
  • 96
marvelX
  • 19
  • 5

2 Answers2

2

Based on the image provided, code will look this way

echo "<pre>";
print_r($levels);
echo "</pre>";

Check your code for syntax errors

Anonymous Duck
  • 2,942
  • 1
  • 12
  • 35
1
Try this code . i will work.
<?php

    $levels = array(
        1 => array( 'name' => 'level 1', 'desc' => 'This is the first level' ),
        2 => array('name' => 'level 2', 'desc' => 'youve made it to level 2!'),
        3 => array('name' => 'level 3', 'desc' => 'The last level')
      );
      echo"<pre>";
      print_r($levels);
      echo "</pre>";
      ?>
Sujeet Kumar
  • 159
  • 6