Reply to Re: [PHP] if(date("Y-m-d") >

Your name:

Reply:


Posted by Travis Conway on 10/01/31 11:05

Maybe this will help. Just keep adding to $var[] until you add all your
weeks. Then execute it. This is written to run on the command line, but
you can replace the \n with <br> to get your breaks in HTML.

<?
$var = Array();
$var[] = "2005-01-02";
$var[] = "2005-01-09";
$var[] = "2005-01-16";

$numweeks = count($var);
echo "Number of weeks: " . $numweeks . "\n";

$today = date("Y-m-d");
for ($i=0;$i<$numweeks;$i++) {
if ($today >= $var[$i]) {
$lastweek = $i + 1;
}
}
echo "This is week $lastweek.\n";
?>

HTH

Trav
www.pinkbunnysuit.com

----- Original Message -----
From: "John Taylor-Johnston" <taylorjo@collegesherbrooke.qc.ca>
To: <php-general@lists.php.net>
Sent: Monday, January 10, 2005 12:08 PM
Subject: [PHP] if(date("Y-m-d") >


> Hi,
> I would like some help to improve this script. I'm a teacher with a
> schedule of 17 weeks.
> Instead of using if(date("Y-m-d") >= $week3) I would like to do a "for i
> = 1 to 17" and if the current date date("Y-m-d") = week[i] I would like to
> echo "This is week $week[i]";
>
> Can someone show me how please?
>
>
> <?php
> #old code:
> $week1 = "2005-01-17";
> $week2 = "2005-01-24";
> ...
> $week17 = "2005-05-09;
>
> if(date("Y-m-d") >= $week3)
> {
> echo "this is week 3");
> }
> ?>
>
> Thanks,
> John
>
> --
> John Taylor-Johnston
> -----------------------------------------------------------------------------
> "If it's not Open Source, it's Murphy's Law."
>
> ''' Collège de Sherbrooke:
> ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
> - 819-569-2064
>
> °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign
> Literatures
> /(_)\ Université de Sherbrooke
> ^ ^ http://compcanlit.ca/ T: 819.569.2064
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация