What is wrong here I need to return an array with the elements 1 thru 31. $name = cal_days_in_month(CAL_GREGORIAN, 5, 2008); for ($i = 1; $i <= $name; $i++) { $val = "$i|"; echo "$i"; } $result = explode('|', $val); foreach ($result as $vals) { echo "$vals"; } ?> I am trying to check if an array now exsist but recieve no result, if I attempt to echo $vals[0] I get the weird result of 3, what am l doing here!!!???
$val .= "$i|"; // ^
Much simpler would be:
$result = range(1, cal_days_in_month(CAL_GREGORIAN, 5, 2008)); // show result: foreach($result as $day) { echo "$day<br />\n"; }
When posting PHP code, please use the board's [PHP][/PHP] bbcode tags - they make the code much, much easier to read (as well as aiding the diagnosis of syntax errors). You should edit your post now and add these bbcode tags to help others in reading/analyzing your code.
If you ever want to see the contents of an array when debugging, I recommend:
$result = range(1, cal_days_in_month(CAL_GREGORIAN, 5, 2008)); // show array contents: echo "<pre>"; var_dump($result); echo "</pre>";