leela Posted April 25, 2007 Share Posted April 25, 2007 Hello, I got the foll O/P: Apr Dec Nov Nov Dec Apr Array ( [Jan] => 01-31 [Feb] => 01-28 [Mar] => 01-31 [Apr] => 01-30 [May] => 01-31 [Jun] => 01-30 [Jul] => 01-31 [Aug] => 01-31 [sep] => 01-30 [Oct] => 01-31 [Nov] => 01-30 [Dec] => 01-31 ) I wrote the same code.Plz recheck the code and send me. Thanks, leela Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/ Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 not sure what your talking about... from what i see... your looking to find how many days are in each month...? this way is far easier... <? function get_daysinmonth($month, $year){ if(checkdate($month, 31, $year)) return 31; elseif(checkdate($month, 30, $year)) return 30; elseif(checkdate($month, 29, $year)) return 29; elseif(checkdate($month, 28, $year)) return 28; return FALSE; } for($i=1; $i<=12; $i++){ $months[$i]=get_daysinmonth($i,date(Y)); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238390 Share on other sites More sharing options...
leela Posted April 25, 2007 Author Share Posted April 25, 2007 <?php // get array of months information $months = array("Jan" => "01-31", "Feb" => "01-28", "Mar" => "01-31", "Apr" => "01-30", "May" => "01-31", "Jun" => "01-30", "Jul" => "01-31", "Aug" => "01-31", "Sep" => "01-30", "Oct" => "01-31", "Nov" => "01-30", "Dec" => "01-31"); // get months $thismonth = date('y'-'m'-'d'); $lastmonth = date('y-m-d')-mktime(0,0,0,date('y')-0,date('m')-1,date('d')-0); echo $lastmonth = date("M", $lastmonth); echo "<br>"; $monthbeforelast = strtotime("-2 month", $thismonth); echo $monthbeforelast; // turn them into the proper format $thismonth = date("M"); $lastmonth = date("M", $lastmonth); $monthbeforelast = date("M", $monthbeforelast); echo $thismonth; echo "<br />"; //echo $lastmonth; echo "<br />"; echo $monthbeforelast; echo "<br />"; ?> <form name="dates" id="dates" action="" method="post"> <select name="months"> <option value="<?php echo $monthbeforelast; ?>"><?php echo $monthbeforelast . $months['$monthbeforelast']; ?></option> <option value="<?php echo $lastmonth; ?>"><?php echo $lastmonth . $months['$lastmonth']; ?></option> <option value="<?php echo $thismonth; ?>"><?php echo $thismonth . $months['$thismonth']; ?></option> </select> </form> <?php print_r($months); ?> i got the above o/p for this question. i require last 3 months . Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238394 Share on other sites More sharing options...
taith Posted April 25, 2007 Share Posted April 25, 2007 three months... as in this month, and three ago? Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238395 Share on other sites More sharing options...
AndyB Posted April 25, 2007 Share Posted April 25, 2007 @ leela: for the non-psychics here, just what is your question? Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238557 Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 If you are after days in a given month (crystal ball a little cloudy) try <?php $month = 'Feb'; $daysInMonth = date('t', strtotime("1-$month")); echo $daysInMonth; // --> 28 ?> Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238659 Share on other sites More sharing options...
clown[NOR] Posted April 26, 2007 Share Posted April 26, 2007 Barand... that printed out 31 for me... had to remove 1- then it showed 28 Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238721 Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 Strange, when I use just the month I always get 31 . Does this work for you? <?php $month = 'Feb'; $daysInMonth = date('t', strtotime("1-$month-".date('Y'))); // 1-Feb-2007 echo $daysInMonth; ?> Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238889 Share on other sites More sharing options...
MadTechie Posted April 26, 2007 Share Posted April 26, 2007 FYI, I got 28 on both Barand Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238910 Share on other sites More sharing options...
clown[NOR] Posted April 26, 2007 Share Posted April 26, 2007 well... i changed $month = 'Feb'; to $month = date("M"); tho... might have been the reason..then I just changed the date on my computer Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-238952 Share on other sites More sharing options...
leela Posted May 5, 2007 Author Share Posted May 5, 2007 Hello EveryOne, I Want to count the characters in text area and limit that count to minimum of 300 characters( actually , this count shud be set by admin in database ) . if the characters are less than 300 , alert message shud come.focus should return to text area. Plz any body help me.I am in need of this. Thanks, Leela Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-246207 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 whats the problem or try the same post here Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-246211 Share on other sites More sharing options...
clown[NOR] Posted May 5, 2007 Share Posted May 5, 2007 you can try using strlen() <?php $string = "blabla this is not more than 300 characters"; if (strlen($string) > 300) { echo "The text contains more than 300 characters"; } else { echo "The text contains less than 300 characters"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48667-doubt/#findComment-246232 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.