Part 7 (Array Functions 2) Problem


#1

Hello, I'm not sure what's wrong with this code. I keep getting the error "Your reverse sorted array should have at least 3 elements in it. Make sure to pass a comma as the first argument to join() !" however, there are four things in the array. Thanks!


<html>
    <p>
	<?php
	// Create an array and push 5 elements on to it, then 
        // print the number of elements in your array to the screen
       $the_array = array(5, 3, 7, 1);
       sort($the_array);
       print join(',', $the_array) . "<p></p>";
       rsort($the_array);
       print join(',', $the_array);
	?>
	</p>
</html>


#2

Try to remove the space between any array like so:
(5,3,7,1);

And where did the "< p>< /p>" came from?


#3

You opened up a paragraph tag, but never closed it. Once that's corrected, it will let you proceed with the next lesson.

<html>
    <p>
	<?php
	[...]
       print join(',', $the_array) . "<p></p>";
       [...]
	?>
	</p>
</html>

correct to:

<html>
    <p>
	<?php
	[...]
       print join(',', $the_array) . "</p><p>";
       [...]
	?>
	</p>
</html>

#4

I believe that is already implemented within the lesson.


#5

try to delete all..........im sure it will solve your problem


#6

Thank you everyone for all the help! It's working now. The paragraph tags on the printing line was the problem.


#7

I had the same error message.

The example has:

print join(":", $array);

For me the problem was the colon.

Change it to (as recommended by the error message):

print join(",", $array);

It then works.

So it looks like the example is wrong.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.