php-general Digest 18 Mar 2009 08:38:29 -0000 Issue 6018
Topics (messages 290182 through 290208):
Re: Multithreading in PHP
290182 by: Manuel Lemos
Re: Fork and zombies
290183 by: Jochem Maas
290184 by: George Larson
290185 by: Ashley Sheridan
290186 by: Per Jessen
290189 by: Jochem Maas
290194 by: Waynn Lue
290195 by: Waynn Lue
290205 by: Per Jessen
Re: mail() is duplicating
290187 by: Manuel Lemos
Form to pdf
290188 by: Gary
290200 by: 9el
assign associative array values to variables?
290190 by: PJ
290192 by: Chris
290196 by: PJ
290197 by: PJ
290198 by: Chris
preg_replace() question
290191 by: PJ
290193 by: Chris
Re: Anyone know of a project like Redmine written in PHP?
290199 by: Jim Lucas
Calendar/Date
290201 by: Jason Todd Slack-Moehrle
290203 by: Paul M Foster
290207 by: Robert Cummings
php-general-sc.1237291233.npmhceaklghpccnefjed-born2victory=gmail....@lists.php.net
290202 by: Born2Win
PHP Quiz
290204 by: satya narayan
290206 by: Ashley Sheridan
290208 by: satya narayan
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hello,
on 03/17/2009 10:14 AM Manoj Singh said the following:
> I am creating a page which submits the form through Ajax request & the
> submitted page is sending the mails to n number of users. Now until the mail
> sends or the page process completed the end user has to wait.
>
> Is it possible that server sends the response to the client & then start
> processing so that the client doesn't have to wait for the server response.
You will need to use AJAX/COMET requests. Regular XMLHttpRequest AJAX
requests will not do because when you send the AJAX response your script
exits.
With AJAX/COMET requests you can send several responses to the same
request without exiting the script, so you can show progress report.
Take a look at these articles:
http://www.phpclasses.org/blog/post/58-Responsive-AJAX-applications-with-COMET.html
http://www.phpclasses.org/blog/post/51-PHPClasses-20-Beta-AJAX-XMLHttpRequest-x-IFrame.html
This forms class comes with an AJAX/COMET plug-in that allows you to
show progress of a task running on the server without page reloading in
a single request.
http://www.phpclasses.org/formsgeneration
Here is is a live example script that show progress of a task running on
the server after the form is submitted.
http://www.meta-language.net/forms-examples.html?example=test_ajax_form
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Per Jessen schreef:
> Waynn Lue wrote:
>
>> (Apologies for topposting, I'm on my blackberry). Hm, so you think
>> exiting from the child thread causes the db resource to get reclaimed?
>>
>
> Yeah, something like that. The connection is definitely closed when the
> child exits.
>
I can confirm this. you definitely need to open a connection for each child
process.
if you require a db connection in the parent process, you should close
it before forking (and then reopen it afterwards if you still need it).
at least that's what I found I had to do when I ran into this.
incidently my forking loop looks like this, very interested to know if
Per can spot any obvious stupidity:
$childProcs = array();
do {
if (count($childProcs) <= $maxChildProcs) {
$site = array_shift($sites);
$pid = pcntl_fork();
} else {
// stay as parent, no fork, try to reduce number of child processes
$site = null;
$pid = null;
}
switch (true) {
case ($pid === -1):
cronLog("error: (in {$thisScript}), cannot initialize worker
process in order to run {$script} for {$site['name']}");
break;
case ($pid === 0):
// we are child
$exit = 0;
$output = array();
// do we want to exec? or maybe include?
if ($doExec) {
exec($script.' '.$site['id'], $output, $exit);
} else {
$output = inc($script);
$output = explode("\n", $output);
}
if ($exit != 0)
cronLog("error: (in {$thisScript}), {$script} reported an error
($exit) whilst processing for {$site['name']}",);
foreach ($output as $line)
cronLog($line);
exit($exit);
break;
default:
// we are parent
$childProcs[] = $pid;
do {
$status = null;
while (pcntl_wait($status, WNOHANG | WUNTRACED) < 1)
usleep(50000);
foreach ($childProcs as $k => $v)
if (!posix_kill($v, 0)) // send signal 'zero' to check
whether process is still 'up'
unset($childProcs[ $k ]);
$childProcs = array_values($childProcs);
if (count($sites))
break; // more sites to run the given script for
if (!count($childProcs))
break; // no more sites to run the given script for and all
children are complete/dead
} while (true);
break;
}
if (!count($sites))
break; // nothing more to do
usleep(50000);
} while (true);
>
> /Per
>
--- End Message ---
--- Begin Message ---
If "Fork and Zombies" was a diner... I would totally eat there.
On Tue, Mar 17, 2009 at 5:00 PM, Jochem Maas <joc...@iamjochem.com> wrote:
> Per Jessen schreef:
> > Waynn Lue wrote:
> >
> >> (Apologies for topposting, I'm on my blackberry). Hm, so you think
> >> exiting from the child thread causes the db resource to get reclaimed?
> >>
> >
> > Yeah, something like that. The connection is definitely closed when the
> > child exits.
> >
>
> I can confirm this. you definitely need to open a connection for each child
> process.
> if you require a db connection in the parent process, you should close
> it before forking (and then reopen it afterwards if you still need it).
>
> at least that's what I found I had to do when I ran into this.
> incidently my forking loop looks like this, very interested to know if
> Per can spot any obvious stupidity:
>
> $childProcs = array();
> do {
> if (count($childProcs) <= $maxChildProcs) {
> $site = array_shift($sites);
> $pid = pcntl_fork();
> } else {
> // stay as parent, no fork, try to reduce number of child processes
> $site = null;
> $pid = null;
> }
>
> switch (true) {
> case ($pid === -1):
> cronLog("error: (in {$thisScript}), cannot initialize worker
> process in order to run {$script} for {$site['name']}");
> break;
>
> case ($pid === 0):
> // we are child
>
> $exit = 0;
> $output = array();
>
> // do we want to exec? or maybe include?
> if ($doExec) {
> exec($script.' '.$site['id'], $output, $exit);
> } else {
> $output = inc($script);
> $output = explode("\n", $output);
> }
>
> if ($exit != 0)
> cronLog("error: (in {$thisScript}), {$script} reported an
> error ($exit) whilst processing for {$site['name']}",);
>
> foreach ($output as $line)
> cronLog($line);
>
> exit($exit);
> break;
>
> default:
> // we are parent
> $childProcs[] = $pid;
>
> do {
> $status = null;
> while (pcntl_wait($status, WNOHANG | WUNTRACED) < 1)
> usleep(50000);
>
> foreach ($childProcs as $k => $v)
> if (!posix_kill($v, 0)) // send signal 'zero' to check
> whether process is still 'up'
> unset($childProcs[ $k ]);
>
> $childProcs = array_values($childProcs);
>
> if (count($sites))
> break; // more sites to run the given script for
> if (!count($childProcs))
> break; // no more sites to run the given script for and
> all children are complete/dead
>
> } while (true);
> break;
> }
>
>
> if (!count($sites))
> break; // nothing more to do
>
> usleep(50000);
> } while (true);
>
>
> >
> > /Per
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Tue, 2009-03-17 at 17:06 -0400, George Larson wrote:
> If "Fork and Zombies" was a diner... I would totally eat there.
For fork sake... ;)
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
> Per Jessen schreef:
>> Waynn Lue wrote:
>>
>>> (Apologies for topposting, I'm on my blackberry). Hm, so you think
>>> exiting from the child thread causes the db resource to get
>>> reclaimed?
>>>
>>
>> Yeah, something like that. The connection is definitely closed when
>> the child exits.
>>
>
> I can confirm this. you definitely need to open a connection for each
> child process. if you require a db connection in the parent process,
> you should close it before forking (and then reopen it afterwards if
> you still need it).
Yep, exactly my thinking.
> at least that's what I found I had to do when I ran into this.
> incidently my forking loop looks like this, very interested to know if
> Per can spot any obvious stupidity:
I doubt it.
I can't quite follow your code after the pcntl_wait where you've got a
pcntl_kill(), but it looks like an insurance policy? "just in case" ?
/Per
--
Per Jessen, Zürich (7.0°C)
--- End Message ---
--- Begin Message ---
Per Jessen schreef:
> Jochem Maas wrote:
>
>> Per Jessen schreef:
>>> Waynn Lue wrote:
>>>
>>>> (Apologies for topposting, I'm on my blackberry). Hm, so you think
>>>> exiting from the child thread causes the db resource to get
>>>> reclaimed?
>>>>
>>> Yeah, something like that. The connection is definitely closed when
>>> the child exits.
>>>
>> I can confirm this. you definitely need to open a connection for each
>> child process. if you require a db connection in the parent process,
>> you should close it before forking (and then reopen it afterwards if
>> you still need it).
>
> Yep, exactly my thinking.
>
>> at least that's what I found I had to do when I ran into this.
>> incidently my forking loop looks like this, very interested to know if
>> Per can spot any obvious stupidity:
>
> I doubt it.
> I can't quite follow your code after the pcntl_wait where you've got a
> pcntl_kill(), but it looks like an insurance policy? "just in case" ?
>
correct, from my reading the pcntl_kill() with a signal argument of zero should
return true if it is *able* to send the signal (but it doesn't actually send
anything),
given that it's only checking it's own children the parent process must able to
send them signals assuming they're not somehow dead ... so yeah, insurance
policy :-)
>
> /Per
>
--- End Message ---
--- Begin Message ---
>
> > Yeah, something like that. The connection is definitely closed when the
> > child exits.
> >
>
> I can confirm this. you definitely need to open a connection for each child
> process.
> if you require a db connection in the parent process, you should close
> it before forking (and then reopen it afterwards if you still need it).
>
I thought that too, but this code seems to work, which seems to imply that
the child doesn't kill the existing db connection.
$conn = mysql_connect($sharedAppsDbHost, $sharedAppsDbUser,
$sharedAppsDbPass, true);
foreach ($things as $thing) {
temp($thing);
}
function temp($thing) {
global $conn;
extract(getInfo($thing)); // this function call uses a shared db
connection
mysqlSelectDb($dbName, $conn); // dbName is a variable gotten from the
above call
$result = mysql_query("SELECT COUNT(*) FROM Users",
$conn);
$row = mysql_fetch_array($result, MYSQL_BOTH);
echo "$row[0]\n";
$pid = pcntl_fork();
if ($pid == -1) {
die("could not fork");
} else if ($pid) {
// parent, return the child pid
echo "child pid $pid waiting\n";
pcntl_waitpid($pid, $status, WNOHANG);
if (pcntl_wifexited($status)) {
echo "finished [$status] waiting\n";
return;
}
} else {
echo "child sleeping\n";
sleep(3);
echo "child done\n";
exit;
}
}
==============
My main problem here is that I have a set of helper functions (getInfo is
one of them) that uses a global db connection that exists in that helper
script. Otherwise, I have to rewrite the function to create a new
connection every time, which I'd like not to.
Waynn
--- End Message ---
--- Begin Message ---
>
> > Yeah, something like that. The connection is definitely closed when the
>> > child exits.
>> >
>>
>> I can confirm this. you definitely need to open a connection for each
>> child process.
>> if you require a db connection in the parent process, you should close
>> it before forking (and then reopen it afterwards if you still need it).
>>
>
> I thought that too, but this code seems to work, which seems to imply that
> the child doesn't kill the existing db connection.
>
> $conn = mysql_connect($sharedAppsDbHost, $sharedAppsDbUser,
> $sharedAppsDbPass, true);
>
> foreach ($things as $thing) {
> temp($thing);
> }
>
> function temp($thing) {
> global $conn;
> extract(getInfo($thing)); // this function call uses a shared db
> connection
> mysqlSelectDb($dbName, $conn); // dbName is a variable gotten from the
> above call
> $result = mysql_query("SELECT COUNT(*) FROM Users",
> $conn);
> $row = mysql_fetch_array($result, MYSQL_BOTH);
> echo "$row[0]\n";
> $pid = pcntl_fork();
> if ($pid == -1) {
> die("could not fork");
> } else if ($pid) {
> // parent, return the child pid
> echo "child pid $pid waiting\n";
> pcntl_waitpid($pid, $status, WNOHANG);
> if (pcntl_wifexited($status)) {
> echo "finished [$status] waiting\n";
> return;
> }
> } else {
> echo "child sleeping\n";
> sleep(3);
> echo "child done\n";
> exit;
> }
> }
>
> ==============
> My main problem here is that I have a set of helper functions (getInfo is
> one of them) that uses a global db connection that exists in that helper
> script. Otherwise, I have to rewrite the function to create a new
> connection every time, which I'd like not to.
>
> Waynn
>
Whoops, I spoke too soon, I think the sleep(3) causes the child not to exit
before the parent. If instead I don't pass WNOHANG to the waitpid command,
it does error out. So it looks like your theory is correct, and I still
have that problem. I guess the only solution is to rewrite the functions to
use a new db connection every time? Or maybe I should just sleep the child
thread for long periods of time and hope the parent thread finishes in time
(which admittedly seems really hacky)?
--- End Message ---
--- Begin Message ---
Waynn Lue wrote:
> Whoops, I spoke too soon, I think the sleep(3) causes the child not to
> exit before the parent. If instead I don't pass WNOHANG to the
> waitpid command, it does error out. So it looks like your theory is
> correct, and I still have that problem. I guess the only solution is
> to rewrite the functions to use a new db connection every time?
Each child should open its own database connection (if it needs one),
and the parent should not keep the connection open at time of fork().
/Per
--
Per Jessen, Zürich (4.6°C)
--- End Message ---
--- Begin Message ---
Hello,
on 03/17/2009 05:34 PM Ashley Sheridan said the following:
>>> I have several forms on my site that use the same sequence of events:
>>> The first script displays and validates the form data, the second
>>> reformats and asks for confirmation or editing, and the third script
>>> sends the data in an email to the relevent people.
>>>
>>> Two of these forms work exactly as they're supposed to but the third
>>> sends duplicate emails to everyone.
>>>
>>> I have looked and looked and I've run diff and I can see no reason why
>>> this should be happening.
>>>
>>> Could someone suggest what I might have wrong?
>> Usually this happens when you have a To: header in the headers parameters.
> Another possibility is that the mail sending is triggered from a page
> that is called from a get request rather than post. Some browsers
> actually make more than one call when the page is get, thereby
> triggering the duplicate mail creation. I had a similar thing with a
> database update once before, it's a bugger to be rid of without
> switching to post.
I suspect that may happen with nervous users that double click form
submit buttons.
Usually I use this forms class that has a built-in feature to show a
form resubmit confirmation message when the use uses the submit function
more than once:
http://www.phpclasses.org/formsgeneration
That feature can be seen in this page:
http://www.meta-language.net/forms-examples.html?example=test_form
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Is it possible to create an online form, that when filled out the fields
will can be placed in a pdf form?
--- End Message ---
--- Begin Message ---
On Wed, Mar 18, 2009 at 3:48 AM, Gary <gwp...@ptd.net> wrote:
> Is it possible to create an online form, that when filled out the fields
> will can be placed in a pdf form?
Yes possible. But you wrote the query in a bit confused way.
Trying to rephrase yours:
you want a form which will let user choose a working form to be placed
in a PDF to be generated?
www.twitter.com/nine_L
--- End Message ---
--- Begin Message ---
I have been tearing out my hair to figure out a way to place array
values into $variables with not much luck. I can echo the array to the
screen but I can not manipulate the results.
I have searched wide and far all day on the web and I find nothing that
points the way how to extract values from an associative array and
assign them to a variable.
I expected to find some elegant way to do it. Here's the code that
outputs the values:
if ( isset( $book_categories[$bookID] ) ) {
foreach ( $book_categories[$bookID] AS $categoryID ) {
if ( isset( $category[$categoryID] ) ) {
echo($category[$categoryID]['category']);
}
}
}
this will echo something like "CivilizationGods And GoddessesHistorical
PeriodsSociology & Anthropology" (I have not added breaks beween the
categories as there is more manipulation needed on them)
This works for as many categories as needed. Manipulating each value
should not be a problem once it is in a string variable using switch and
preg_replace() as each category needs to be stripped of spaces, commas
and &s.
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
PJ wrote:
I have been tearing out my hair to figure out a way to place array
values into $variables with not much luck. I can echo the array to the
screen but I can not manipulate the results.
I have searched wide and far all day on the web and I find nothing that
points the way how to extract values from an associative array and
assign them to a variable.
I expected to find some elegant way to do it. Here's the code that
outputs the values:
if ( isset( $book_categories[$bookID] ) ) {
foreach ( $book_categories[$bookID] AS $categoryID ) {
if ( isset( $category[$categoryID] ) ) {
echo($category[$categoryID]['category']);
}
}
}
Same as other variable assignment.
if ( isset( $category[$categoryID] ) ) {
$myvar = $category[$categoryID];
}
echo $myvar . "<br/>";
Doing it with a multi-dimensional array is no different to a result set
from a database or any other scenario.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Chris wrote:
> PJ wrote:
>> I have been tearing out my hair to figure out a way to place array
>> values into $variables with not much luck. I can echo the array to the
>> screen but I can not manipulate the results.
>> I have searched wide and far all day on the web and I find nothing that
>> points the way how to extract values from an associative array and
>> assign them to a variable.
>> I expected to find some elegant way to do it. Here's the code that
>> outputs the values:
>> if ( isset( $book_categories[$bookID] ) ) {
>> foreach ( $book_categories[$bookID] AS $categoryID ) {
>> if ( isset( $category[$categoryID] ) ) {
>> echo($category[$categoryID]['category']);
>> }
>> }
>> }
>
> Same as other variable assignment.
>
> if ( isset( $category[$categoryID] ) ) {
> $myvar = $category[$categoryID];
> }
>
> echo $myvar . "<br/>";
>
> Doing it with a multi-dimensional array is no different to a result
> set from a database or any other scenario.
>
I probably did not express myself clearly; I thought I did:
"place array * *values ** into * *$variables **"
the output of $myvar above is Array. That, I knew. And that does not
extract. I can see what is in the array in several ways; the problem is
to get the output into $var1, $var2, $var3 ... etc. How do I convert:
$category[$categoryID]['category'] into up to 4 different variables that I can
manipulate?
My code above outputs text like this: "CivilizationGods And GoddessesHistorical
PeriodsSociology & Anthropology"
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
dg wrote:
> If I'm understanding your question correctly, this may help:
>
> <?php
>
> $array = array("value_one" => "red", "value_two" => "blue");
> extract($array);
> print "$value_one, $value_two";
>
Thanks for the suggestion. I've seen that example and have tried it as
well as about a dozen others.
The problem is that the $array returns another array (multidimensional
and associative ?? )
print_r($myarray) returns for example:
Array ( [id] => 5 [category] => Some category)
Array ( [id] => 33 [category] => Another category)
So, you see, I can't do anything with that. I had hoped to be able to
use something like count() or $row() or foreach or while but no go.
foreach may have a possibility but it it rather convoluted and I'm
trying to avoid it; hoping for something simpler, more logical and more
"elegant".
> ?>
> On Mar 17, 2009, at 4:27 PM, PJ wrote:
>
>> I have been tearing out my hair to figure out a way to place array
>> values into $variables with not much luck. I can echo the array to the
>> screen but I can not manipulate the results.
>> I have searched wide and far all day on the web and I find nothing that
>> points the way how to extract values from an associative array and
>> assign them to a variable.
>> I expected to find some elegant way to do it. Here's the code that
>> outputs the values:
>> if ( isset( $book_categories[$bookID] ) ) {
>> foreach ( $book_categories[$bookID] AS $categoryID ) {
>> if ( isset( $category[$categoryID] ) ) {
>> echo($category[$categoryID]['category']);
>> }
>> }
>> }
>>
>> this will echo something like "CivilizationGods And GoddessesHistorical
>> PeriodsSociology & Anthropology" (I have not added breaks beween the
>> categories as there is more manipulation needed on them)
>>
>> This works for as many categories as needed. Manipulating each value
>> should not be a problem once it is in a string variable using switch and
>> preg_replace() as each category needs to be stripped of spaces, commas
>> and &s.
>>
>> --
>> unheralded genius: "A clean desk is the sign of a dull mind. "
>> -------------------------------------------------------------
>> Phil Jourdan --- p...@ptahhotep.com
>> http://www.ptahhotep.com
>> http://www.chiccantine.com/andypantry.php
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
PJ wrote:
Chris wrote:
PJ wrote:
I have been tearing out my hair to figure out a way to place array
values into $variables with not much luck. I can echo the array to the
screen but I can not manipulate the results.
I have searched wide and far all day on the web and I find nothing that
points the way how to extract values from an associative array and
assign them to a variable.
I expected to find some elegant way to do it. Here's the code that
outputs the values:
if ( isset( $book_categories[$bookID] ) ) {
foreach ( $book_categories[$bookID] AS $categoryID ) {
if ( isset( $category[$categoryID] ) ) {
echo($category[$categoryID]['category']);
}
}
}
Same as other variable assignment.
if ( isset( $category[$categoryID] ) ) {
$myvar = $category[$categoryID];
}
echo $myvar . "<br/>";
Doing it with a multi-dimensional array is no different to a result
set from a database or any other scenario.
I probably did not express myself clearly; I thought I did:
"place array * *values ** into * *$variables **"
Try this
$my_categories = array();
foreach (......) {
if (isset($category[$categoryID])) {
$my_categories[] = $category[$categoryID]['category'];
}
}
At the end, you can either:
foreach ($my_categories as $category_name) {
.. do something
}
or
$category_list = implode(',', $my_categories);
echo "The categories are ${category_list}\n";
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
1. What is the overhead on preg_replace?
2. Is there a better way to strip spaces and non alpha numerical
characters from text strings? I suspect not... maybe the Shadow does ???
:-D
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php
--- End Message ---
--- Begin Message ---
PJ wrote:
1. What is the overhead on preg_replace?
Compared to what? If you write a 3 line regex, it's going to take some
processing.
2. Is there a better way to strip spaces and non alpha numerical
characters from text strings? I suspect not... maybe the Shadow does ???
For this, preg_replace is probably the right option.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hmmm.... needs some help indeed...
http://www.jotbug.org/help
Jan G.B. wrote:
Yes, recently the developer of "JotBug" anounced his project. I guess
the project still needs help.
All I have is the public CVS acces so far..
Check out
http://www.jotbug.org/projects
http://code.google.com/p/jotbug/
byebye
2009/3/17 mike <mike...@gmail.com>:
http://www.redmine.org/
Looks pretty useful; I want one in PHP though.
Anyone?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Hi All,
Does anyone have code and/or advice for how to get get the current
week (with a passed current day, say) and what then end date is at
Saturday.
So take today: Tuesday March 17, 2009
I want to get:
Sunday March 15, 2009
Monday March 16, 2009
Tuesday March 17, 2009
Wednesday March 18, 2009
Thursday March 19, 2009
Friday March 20, 2009
Saturday March 21, 2009
Thanks!
-Jason
--- End Message ---
--- Begin Message ---
On Tue, Mar 17, 2009 at 08:52:11PM -0700, Jason Todd Slack-Moehrle wrote:
> Hi All,
>
> Does anyone have code and/or advice for how to get get the current
> week (with a passed current day, say) and what then end date is at
> Saturday.
>
> So take today: Tuesday March 17, 2009
>
> I want to get:
> Sunday March 15, 2009
> Monday March 16, 2009
> Tuesday March 17, 2009
> Wednesday March 18, 2009
> Thursday March 19, 2009
> Friday March 20, 2009
> Saturday March 21, 2009
I just answered a question similar to this. You might check the
archives. In this case, you'll need to use the getdate() function (see
php.net/manual/en/ for details) to get the array of values for today
(like the day of the month, month number, year, etc.). The getdate()
function returns an array, one of whose members is 'wday', which is the
day of the week, starting with 0 for Sunday. Use that number to
determine how many days to go back from today. Then use mktime() to get
the timestamps for each day in turn. You feed mktime() values from the
getdate() call. Then you can use strftime() or something else to print
out the dates in whatever format, given the timestamps you got.
Be careful in feeding values to mktime(). If your week spans a
month or year boundary, you'll need to compensate for it when giving
mktime() month numbers, day numbers and year numbers.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Tue, 2009-03-17 at 20:52 -0700, Jason Todd Slack-Moehrle wrote:
> Hi All,
>
> Does anyone have code and/or advice for how to get get the current
> week (with a passed current day, say) and what then end date is at
> Saturday.
>
> So take today: Tuesday March 17, 2009
>
> I want to get:
> Sunday March 15, 2009
> Monday March 16, 2009
> Tuesday March 17, 2009
> Wednesday March 18, 2009
> Thursday March 19, 2009
> Friday March 20, 2009
> Saturday March 21, 2009
A sprinkle of math + a sprinkle of time + a sprinkle of PHP:
<?php
$dates = array();
$offset = (int)date( 'w' ) - 6;
for( $i = 0; $i < 7; $i++ )
{
$dates[] = date( 'l F j, Y', strtotime( '+'.($offset + $i).'
days' ) );
}
print_r( $dates );
?>
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
--- End Message ---
--- Begin Message ---
Hello Friends,
I have started a FREE site for quizzes for PHP.
I need your kind help, if possible please visit the site and take some
quizzes, and then let me know your feedback. Should I add any thing
else in that site?
link: http://www.testmyphp.com
Thanks in advance.
--
Satya
Bangalore.
--- End Message ---
--- Begin Message ---
On Wed, 2009-03-18 at 10:57 +0530, satya narayan wrote:
> Hello Friends,
>
> I have started a FREE site for quizzes for PHP.
>
> I need your kind help, if possible please visit the site and take some
> quizzes, and then let me know your feedback. Should I add any thing
> else in that site?
>
>
> link: http://www.testmyphp.com
>
>
> Thanks in advance.
>
>
> --
> Satya
> Bangalore.
>
Maybe get rid of the required login to do anything :p
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi ash,
Thanks for your feedback first.
Actually registration helps admin to track an user . Additionally if
you are registered you can see your previous results for different
Quizzes. That's what I thought It is good to have registration
restriction. I think its a small cost to pay for an User if all the
Quizzes are being provided Free.
If majority will say to remove the registration process I can do so.
--
Thanks and Regards.
Satya
On 3/18/09, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> On Wed, 2009-03-18 at 10:57 +0530, satya narayan wrote:
>> Hello Friends,
>>
>> I have started a FREE site for quizzes for PHP.
>>
>> I need your kind help, if possible please visit the site and take some
>> quizzes, and then let me know your feedback. Should I add any thing
>> else in that site?
>>
>>
>> link: http://www.testmyphp.com
>>
>>
>> Thanks in advance.
>>
>>
>> --
>> Satya
>> Bangalore.
>>
> Maybe get rid of the required login to do anything :p
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
--- End Message ---