briintex1
09-20-2004, 03:04 AM
I am tryin' to figure out if I am doing functions right or not. I was wondering if I could return an array, I know if other lang. like C++ and vb you can return an array but this is primarly setting a variable as the number inside the array.
I know right now I have an error on line #2 the error reads
Parse error: parse error, unexpected '[', expecting ')' in /home/cypressp/public_html/test.php on line 2
<?
function random_quotes($quotes[random_number])
//the following sets ththe array for the quotes
$quotes[] = 'First quote';
$quotes[] = 'Second quote';
$quotes[] = 'Third quote';
//the following sets the random number to be put in the array so the quote will be choosen
srand ((double) microtime() * 1000000);
$random_number = rand(0,count($quotes)-1);
return $quotes[$random_number];
?>
<html>
<title>CodeAve.com (JavaScript: Textbox Change OnClick)</title>
<body bgcolor="#FFFFFF">
<?
random_quotes($quotes[$random_number]; //this line should call the function
$that2 = $quotes[$random_number]; //I set this here so I can call the function and set it to a variable
random_quotes($quotes[$random_number]; //this line should call the function
$that1 = $quotes[$random_number]; //I set this here so I can call the function and set it to a variable that way it will be different than the one aboveecho($that2);
echo($that1);
?>
</body>
</html>
Thanks in advance for the help
I know right now I have an error on line #2 the error reads
Parse error: parse error, unexpected '[', expecting ')' in /home/cypressp/public_html/test.php on line 2
<?
function random_quotes($quotes[random_number])
//the following sets ththe array for the quotes
$quotes[] = 'First quote';
$quotes[] = 'Second quote';
$quotes[] = 'Third quote';
//the following sets the random number to be put in the array so the quote will be choosen
srand ((double) microtime() * 1000000);
$random_number = rand(0,count($quotes)-1);
return $quotes[$random_number];
?>
<html>
<title>CodeAve.com (JavaScript: Textbox Change OnClick)</title>
<body bgcolor="#FFFFFF">
<?
random_quotes($quotes[$random_number]; //this line should call the function
$that2 = $quotes[$random_number]; //I set this here so I can call the function and set it to a variable
random_quotes($quotes[$random_number]; //this line should call the function
$that1 = $quotes[$random_number]; //I set this here so I can call the function and set it to a variable that way it will be different than the one aboveecho($that2);
echo($that1);
?>
</body>
</html>
Thanks in advance for the help