Since $colour is assigned outside the function, it is in the global scope.
Add the line "global $colour;" to the function to use $colour in the
function's local scope.
Kirk
> -----Original Message-----
> From: Subodh Gupta [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 24, 2001 11:54 AM
> To: PHP General
> Subject: [PHP] A simple problem!
>
>
> Can You figure out the mistake here...??
>
> In the following code... In the function print_entry which I
> am calling in some other file, I want each entry to printed
> in a different colour.
>
> $colour = array("808080","800000","FF00FF","0000FF","008080");
> $colouroffset=0;
>
>
> function print_entry($row,$preserve="")
> {
>
> // walk through any arguments passed in after the first two
> $numargs = func_num_args();
> for ($i = 2; $i < $numargs; $i++)
> {
> $field = func_get_arg($i);
>
> // This will transform a label string to a valid database
> // field name - e.g., "Last Name" becomes "last_name"
> $dbfield = str_replace(" ", "_", strtolower($field));
>
> $dbvalue = cleanup_text($row[$dbfield],$preserve);
> $name = ucwords($field);
>
> print <<<EOQ
> <tr>\n
> <td valign=top align=right><b><font
> color="#$colour[$colouroffset]">$name:</font></b></td>\n //
> The problem is here.. the value of $colour[$colouroffset] is
> not <td valign=top align=left><font
> color="#$colour[$colouroffset]">$dbvalue</font></td>\n
> // getting substituted. Can you tell me why??
> </tr>\n\n
> EOQ;
> }
>
> $colouroffset++;
> }
>
> Subodh Gupta
> I have learned, Joy is not in things, it is in us.
> You will ultimately be known by what you give and not what you get.
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]