This forum is now read-only. Please use our new forums! Go to forums
Where is my syntax error?!
Hi,
In result:
PHP Parse error: syntax error, unexpected T_PRINT in /root/adapter/runners/runner.php(47) : eval()’d code on line 14
index.php
<html>
<p>
<?php
// Create an array and push on the names
// of your closest family and friends
$family_friends = array("Father", "Mather", "Sister", "Dragoev",
"Ralev", "Veliko");
array_push($family_friends, "Petyo");
// Sort the list
sort($family_friends);
// Randomly select a winner!
$winner = rand($family_friends[0] , count($family_friends) - 1)
// Print the winner's name in ALL CAPS
print strtoupper($winner);
?>
</p>
Answer 5151853d8f002e2b68001cd2
Answer 514fe05134cba31136000060
Answer 51501559afb1438f500003ff
Ok, but now where I wrong?!
<html>
<p>
<?php
// Create an array and push on the names
// of your closest family and friends
$users = array("Veliko", "Dragov", "Ralev");
array_push($users, "Petyo");
// Sort the list
$sort_users = sort($users);
// Randomly select a winner!
$winner = rand(0, count($sort_users) - 1);
// Print the winner's name in ALL CAPS
print strtoupper($winner);
?>
</p>
Result
0
Answer 515074e41f6c225220000ce6
You need the print winner’s name:
$winnerName = strtoupper($names[$winner]);
print $winnerName;
Answer 5157378fa568f96b6700005c
ok where am i wrong, i get this error message:
PHP Warning: rand() expects parameter 1 to be long, string given in /root/adapter/runners/runner.php(47) : eval()’d code on line 10 PHP Notice: Undefined index: in /root/adapter/runners/runner.php(47) : eval()’d code on line 11
my code:
1 comments
$array[1] is not an integer, it is the second element of your array (fuzzy after sort). You obviously can not generate a random integer between fuzzy and 4. Instead of $array[1] in random, use 0.
Answer 522ef4b7f10c600ba8001c25
Answer 532ab51852f8636e7c00179b
$familyfriends = array(); array_push($familyfriends, “Matt”); array_push($familyfriends, “Momo”); array_push($familyfriends, “Comit”); // Sort the list sort($familyfriends); // Randomly select a winner! // Print the winner’s name in ALL CAPS print strtoupper($familyfriends[rand(0, count($familyfriends) - 1)]);
1 comments
please put underscore in line 1 & 2 like (array_push)..thank u..
Answer 53cd66c852f863a65f000363
Answer 547422d69c4e9d74a4000fc5
Answer 557014cad3292f883d000365
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
Thanks a lot!