php - Foreach statement inside a called function gives an error -
i insert foreach()
statement, suppose display year value dynamically,into called function keeps giving errors... extract of doing
$display->content( 'the heading <select name="year" id="year">'. foreach(range(date("y",2013) $value){ echo "<option value=\"$value\">$value</option>\n"; } .'</select> script ends' );
this error receive time execute parse error: syntax error, unexpected 'foreach' (t_foreach) in /var/www/test.php on line 140
. please help deal appreciated. give thanks you.
your code syntactically invalid. next should work.
$options = ""; foreach(range(date("y",2013)) $value) { $options .= '<option value="'.$value.'">$value</option>'; } $display->content( 'the heading <select name="year" id="year">'. $options .'</select> script ends' );
php function
No comments:
Post a Comment