View Full Version : super newbie project, trying to use array attributes in a function but get error

09-07-2009, 10:43 PM
hi, my teacher told me to use an array to control the look of a table. and im trying, but have no idea if this is valid code. i also get the error

Parse error: parse error, expecting `')'' in C:\wamp\www\lessons\table\table.php on line 46

please, any advice or help greatly appreciated. thank you. derek

here is the code


//table options multidimensional array

$table_options = array(
'color1'=> 'blue',
'color2'=> 'green',
'color3'=> 'red',
'color4'=> 'orange',
'color5'=> 'purple',
'color6'=> 'yellow'
'width1' => '20%',
'width2' => '50%',
'width3' => '70%',
'width4' => '90%',
'width5' => '100%'
'border1' => '0',
'border2' => '1'

'rows1'=> '1',
'rows2'=> '2',
'rows3'=> '3',
'rows4'=> '4',
'rows5'=> '5'

///setting and outputting the table functions

//declaring the array attributes as the function arguments.

function table_setter($table_options['color'][],$table_options['width'][],$table_options['border'][], $table_options['row_num'][]){

///youre altering the table dimensions with php!!!
$table .= "<table background-color=\"$table_options['color'][]\" width=\"$table_options['width'][]\" border=\"$table_options['border'][]\" >
<td>header 1</td>
<td>header 2</td>
<td>header 3</td>


$table .= "<tr>


$table .= "</table>";

return $table;


echo table_setter($table_options['color']['color1'],$table_options['width']['width3'],$table_options['border']['border2'], $table_options['row_num']['rows5']);

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


09-07-2009, 11:29 PM
nevermind i think im ditching the assignment i dont think i have a good idea of what the assignment was supposed to do.

09-09-2009, 07:10 PM
Too bad, the error message was verbal and told you exactly what was wrong :-/

09-13-2009, 09:45 AM
looks good code, you do know what your doing so dont give up!! just post line lines 40 to 50 please