8. Show what You know


#1
<html>
    <p>
	<?php
	// Create an array and push on the names
    // of your closest family and friends
    $family = array();
        array_push($family, "Deep");
        array_push($family, "avi");
        array_push($family, "Avro");
        array_push($family, "Munai");
	// Sort the list
    $sorted = sort($family);
    
	// Randomly select a winner!
    $random = rand(0, count($sorted)-1);
	// Print the winner's name in ALL CAPS
	$select = $sorted[$random];
	print strtoupper($select);
	
	?>
   </p>
</html>

Please guide me,


#2

Hi @itsamartya,

Please give the error you get as well as the exercise link.

Thanks!


#3

@gaurangtandon
Its saying :innocent:

Oops, try again. Remember to print out the name of the lucky winner!


#4

@gaurangtandon dear.. I have solved it, .. Thanks for checking .. :icecream:


#5

Glad to know that you solved it yourself :slightly_smiling: Please post the solution as well for any future reader who may come by this post. Thanks!


#6
<html>
    <p>
	<?php
	// Create an array and push on the names
    // of your closest family and friends
    $family = array();
        array_push($family, "Deep");
        array_push($family, "avi");
        array_push($family, "Avro");
        array_push($family, "Munai");
	// Sort the list
    $sorted = sort($family);
    
	// Randomly select a winner!
    $count = count($family);
    $rand = rand(0, $count - 1);
	// Print the winner's name in ALL CAPS
	print strtoupper($family[$rand]);
	
	
	?>
	</p>
</html>

Sir @gaurangtandon .. Check this.. hope you will appreciate ..


#7

Many thanks.
I think the compiler of this website has some problems about checking code syntax.


#8

I completed the exercise but didn't need a few of the instructions to complete it. I'm not sure if I did the code incorrectly or if there is a bug in the exercise. I added sort($bffs); and count($bffs); but it worked correctly without them. Here it is:



<?php
$bffs = array();
array_push($bffs, "Amy");
array_push($bffs, "Thomas");
array_push($bffs, "Chase");
sort($bffs);
count($bffs);
$winner = strtoupper($bffs[rand(0,2)]);
print $winner;
?>



#9

your code is not working .....


#10

This is working, Finally !!