This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

323 points
14fac250d4f382f71cc1307543515c18?s=140&d=retro
Submitted by
Osiansmith
almost 3 years ago

Parse error: syntax error, unexpected T_VARIABLE on line 8 error

Hello all, I'm getting this error when I submit it in the preivew box:
Parse error: syntax error, unexpected T_VARIABLE on line 8
This is my code:


<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
$numbers = array(2,3,4,5,1,5,6,7,8,12);
sort($numbers);
print join("," $numbers);
?>


<?php
// Reverse sort your array and print the joined elements to the screen
rsort($numbers);
print join(",", $numbers)
?>


What is wrong with it?
Thanks


0 votes

permalink

<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
$thearray = array(2,3,4,5,1,5,6,7,8,12);
sort($the
array );
print join(", ", $the_array );
?>

<?php
// Reverse sort your array and print the joined elements to the screen
rsort($thearray );
print join(",", $the
array )
?>

Main thing is you were missing a comma here join(", ", $the_array );

438 points
4fb6fcef6ef03c0003022d66_274823844
Submitted by
smartalec
almost 3 years ago

1 Comment

4fb6fcef6ef03c0003022d66_274823844 smartalec almost 3 years ago

Oh and you were missing the paragraph tags so that caused the output to show up inline. The CodeAcademy validator will get you for that