|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Wed May 23 2007 - 01:39:46 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 23 May 2007 06:39:46 -0000 Issue 4806
Topics (messages 255330 through 255367):
Re: convert numerical day of week
255330 by: Daniel Brown
255331 by: Richard Davey
255332 by: Greg Donald
255333 by: Daniel Brown
255335 by: Greg Donald
255336 by: Daniel Brown
255337 by: Robert Cummings
255338 by: Greg Donald
255340 by: Robert Cummings
255342 by: Daniel Brown
255343 by: Greg Donald
255344 by: Robert Cummings
255345 by: Robert Cummings
255346 by: Daniel Brown
255347 by: Robert Cummings
255348 by: Daniel Brown
255352 by: Greg Donald
255353 by: Robert Cummings
255354 by: Greg Donald
255355 by: Robert Cummings
255356 by: Greg Donald
255357 by: Tom Rogers
255358 by: Robert Cummings
255359 by: tg-php.gryffyndevelopment.com
255360 by: Robert Cummings
255361 by: Davi
255364 by: itoctopus
Re: PHP Data Mining/Data Scraping
255334 by: Tijnema
255351 by: Myron Turner
Re: ftp root dir?
255339 by: Johan Holst Nielsen
255350 by: Al
Re: Regular Expressions
255341 by: Jochem Maas
Re: [PEAR] PHP5 Static functions called through __call() that don't exist... yet
255349 by: Jared Farrish
Syntax error, where?
255362 by: jekillen
Syntax error, where? solved
255363 by: jekillen
Re: Enabling LDAP on Plesk 8
255365 by: itoctopus
255366 by: itoctopus
problem with composing URL with GET Variables
255367 by: Angelo Zanetti
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Do you mean by using the date() function?
On 5/22/07, Bosky, Dave <Dave.Bosky
htcinc.net> wrote:
>
> How can I convert the numerical day of week to the string version?
>
> Example, if the day of the week is 1 I would like to print out 'Sunday'.
>
>
>
> Thanks,
>
> Dave
>
>
>
>
> **********************************************************************
> HTC Disclaimer: The information contained in this message may be
> privileged and confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by replying to the
> message and deleting it from your computer. Thank you.
> **********************************************************************
>
>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
Hi Dave,
Tuesday, May 22, 2007, 5:46:38 PM, you wrote:
> How can I convert the numerical day of week to the string version?
> Example, if the day of the week is 1 I would like to print out 'Sunday'.
$days = array(1 => 'Sunday', 2 => 'Monday', 3 => 'Tuesday', etc ...);
then just
$today = $days[1]; // Sunday
$today = $days[3]; // Tuesday
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
attached mail follows:
On 5/22/07, Bosky, Dave <Dave.Bosky
htcinc.net> wrote:
> How can I convert the numerical day of week to the string version?
>
> Example, if the day of the week is 1 I would like to print out 'Sunday'.
$days = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday' );
$day = 1;
echo $days[ $day - 1 ];
--
Greg Donald
http://destiney.com/
attached mail follows:
In that case, one simple way (though not the most economical way, and
really hacky, reinventing the wheel in the process) would be to create a
function like so:
<?
function num2day($num) {
if($num == "1") {
$day = "Sunday";
} elseif($num == "2") {
$day = "Monday";
} elseif($num == "3") {
$day = "Tuesday";
} elseif($num == "4") {
$day = "Wednesday";
} elseif($num == "5") {
$day = "Thursday";
} elseif($num == "6") {
$day = "Friday";
} elseif($num == "7") {
$day = "Saturday";
}
return $day;
}
?>
On 5/22/07, Bosky, Dave <Dave.Bosky
htcinc.net> wrote:
>
> I'm not really sure. I've got a numerical interpretation of the day of
> the week in a table and I need to print out what day of the week it
> translates to.
>
> I tried using date_format in the MySQL query but it didn't seem to work.
>
>
>
>
> ------------------------------
>
> *From:* Daniel Brown [mailto:parasane
gmail.com]
> *Sent:* Tuesday, May 22, 2007 12:50 PM
> *To:* Bosky, Dave
> *Cc:* php-general
lists.php.net
> *Subject:* Re: [PHP] convert numerical day of week
>
>
>
>
> Do you mean by using the date() function?
>
> On 5/22/07, *Bosky, Dave* <Dave.Bosky
htcinc.net> wrote:
>
> How can I convert the numerical day of week to the string version?
>
> Example, if the day of the week is 1 I would like to print out 'Sunday'.
>
>
>
> Thanks,
>
> Dave
>
>
>
>
> **********************************************************************
> HTC Disclaimer: The information contained in this message may be
> privileged and confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by replying to the
> message and deleting it from your computer. Thank you.
> **********************************************************************
>
>
>
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On 5/22/07, Daniel Brown <parasane
gmail.com> wrote:
> <?
> function num2day($num) {
> if($num == "1") {
> $day = "Sunday";
> } elseif($num == "2") {
> $day = "Monday";
> } elseif($num == "3") {
> $day = "Tuesday";
> } elseif($num == "4") {
> $day = "Wednesday";
> } elseif($num == "5") {
> $day = "Thursday";
> } elseif($num == "6") {
> $day = "Friday";
> } elseif($num == "7") {
> $day = "Saturday";
> }
> return $day;
> }
> ?>
PHP does automatic type conversions, even if $num is passed in as a
string all those quotes around the integers are not necessary. There
is no variable interpolation required in the day names so all those
double quotes should be single quotes. A function call seems rather
heavy when a global array can be indexed more easily. Even a switch
statement would be an improvement.
--
Greg Donald
http://destiney.com/
attached mail follows:
On 5/22/07, Greg Donald <gdonald
gmail.com> wrote:
>
> On 5/22/07, Daniel Brown <parasane
gmail.com> wrote:
> > <?
> > function num2day($num) {
> > if($num == "1") {
> > $day = "Sunday";
> > } elseif($num == "2") {
> > $day = "Monday";
> > } elseif($num == "3") {
> > $day = "Tuesday";
> > } elseif($num == "4") {
> > $day = "Wednesday";
> > } elseif($num == "5") {
> > $day = "Thursday";
> > } elseif($num == "6") {
> > $day = "Friday";
> > } elseif($num == "7") {
> > $day = "Saturday";
> > }
> > return $day;
> > }
> > ?>
>
> PHP does automatic type conversions, even if $num is passed in as a
> string all those quotes around the integers are not necessary. There
> is no variable interpolation required in the day names so all those
> double quotes should be single quotes. A function call seems rather
> heavy when a global array can be indexed more easily. Even a switch
> statement would be an improvement.
>
>
> --
> Greg Donald
> http://destiney.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You may have noticed my disclaimer at the head of the message. It was
there for just that reason....
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On Tue, 2007-05-22 at 12:46 -0400, Bosky, Dave wrote:
> How can I convert the numerical day of week to the string version?
>
> Example, if the day of the week is 1 I would like to print out 'Sunday'.
I saw a bunch of bad examples given to you that completely ignore any
available locale information... so here's a better version:
<?php
function dayIdToName( $id )
{
static $days = null;
if( $days === null )
{
$control = gmmktime( 12, 1, 1, 5, 20, 2007 );
for( $i = 0; $i < 7; $i++ )
{
$days[$i] = gmdate( 'l', $control + ($i * 24 * 60 * 60) );
}
}
return isset( $days[$id] ) ? $days[$id] : null;
}
?>
If you want Monday to be the first day of the week, just use a date for
gmmktime() that falls on a Monday.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> I saw a bunch of bad examples given to you that completely ignore any
> available locale information... so here's a better version:
I seem to have missed the part of the question where it said
considering locale was important.
--
Greg Donald
http://destiney.com/
attached mail follows:
On Tue, 2007-05-22 at 12:58 -0500, Greg Donald wrote:
> On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > I saw a bunch of bad examples given to you that completely ignore any
> > available locale information... so here's a better version:
>
> I seem to have missed the part of the question where it said
> considering locale was important.
Nothing said it was important, but why implement a half-assed solution
when you can implement a superior solution in as much time?
I'll accept ignorance and sloppiness as reasons... albeit not good
reasons.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
>
> On Tue, 2007-05-22 at 12:58 -0500, Greg Donald wrote:
> > On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > > I saw a bunch of bad examples given to you that completely ignore any
> > > available locale information... so here's a better version:
> >
> > I seem to have missed the part of the question where it said
> > considering locale was important.
>
> Nothing said it was important, but why implement a half-assed solution
> when you can implement a superior solution in as much time?
>
> I'll accept ignorance and sloppiness as reasons... albeit not good
> reasons.
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting |
> | a powerful, scalable system for accessing system services |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for |
> | creating re-usable components quickly and easily. |
> `------------------------------------------------------------'
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
My message was in direct response to the user's request.... I think that
kinda' got lost somewhere in this thread....
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> Nothing said it was important, but why implement a half-assed solution
> when you can implement a superior solution in as much time?
Your solution contains overhead you don't even know you need. Coding
for locales is an edge case since most PHP installs will find the
server settings sufficient.
http://en.wikipedia.org/wiki/YAGNI
> I'll accept ignorance and sloppiness as reasons... albeit not good
> reasons.
You assume too much and your solution is bloated. Accept that.
--
Greg Donald
http://destiney.com/
attached mail follows:
On Tue, 2007-05-22 at 14:32 -0400, Daniel Brown wrote:
> On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> >
> > On Tue, 2007-05-22 at 12:58 -0500, Greg Donald wrote:
> > > On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > > > I saw a bunch of bad examples given to you that completely ignore any
> > > > available locale information... so here's a better version:
> > >
> > > I seem to have missed the part of the question where it said
> > > considering locale was important.
> >
> > Nothing said it was important, but why implement a half-assed solution
> > when you can implement a superior solution in as much time?
> >
> > I'll accept ignorance and sloppiness as reasons... albeit not good
> > reasons.
>
> My message was in direct response to the user's request.... I think that
> kinda' got lost somewhere in this thread....
I didn't respond to your message. I responded directly to the OP's
original post.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On Tue, 2007-05-22 at 13:47 -0500, Greg Donald wrote:
> On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > Nothing said it was important, but why implement a half-assed solution
> > when you can implement a superior solution in as much time?
>
> Your solution contains overhead you don't even know you need. Coding
> for locales is an edge case since most PHP installs will find the
> server settings sufficient.
>
> http://en.wikipedia.org/wiki/YAGNI
>
> > I'll accept ignorance and sloppiness as reasons... albeit not good
> > reasons.
>
> You assume too much and your solution is bloated. Accept that.
No, your solution is bloated. Mine may run a tad slower, but it consumes
less memory since it uses the weekday names already defined in the
locale. Yours redefines the strings thus requiring that much extra
storage. Yours is redundant with information already available in the
locale. The YAGNI claim is irrelevant here since I'm producing the
requested functionality that the poster obviously needs. Whether I use
your method or my method is irrelevant to YAGNI.
Thank you, try again.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
:: yawns ::
After all the bickering, I wouldn't be surprised if the OP never asks a
question here again.
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On Tue, 2007-05-22 at 15:00 -0400, Daniel Brown wrote:
>
> :: yawns ::
>
> After all the bickering, I wouldn't be surprised if the OP never
> asks a question here again.
Who's bickering? When did a simple discussion become bickering? Maybe
you should take a nap... you're obviously tired. Works for my kids.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
You amuse me, but it's not worth getting into a discussion over.
Enjoy the rest of your day!
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> No, your solution is bloated. Mine may run a tad slower,
Two function calls wrapped in a function will be slower. Tad or a
lot, slower is still slower.
> but it consumes
> less memory since it uses the weekday names already defined in the
> locale.
Looks to me like your version consumes more memory:
> ps aux|grep php
destiney 9448 0.0 -0.2 72596 4760 p2 S+ 4:40PM 0:00.03
php simple.php
destiney 9449 0.0 -0.2 72596 4852 p1 S+ 4:40PM 0:00.03
php locale.php
> Yours redefines the strings thus requiring that much extra
> storage. Yours is redundant with information already available in the
> locale.
You're specializing for an edge case before you even know if you need
to or not. As I've shown above memory is saved by defining your own
list of days. I'm sure given the right conditions your function would
be of great use. Maybe later on someone will actually ask about
locales, then you can repost it and it can become relevant.
> The YAGNI claim is irrelevant here since I'm producing the
> requested functionality that the poster obviously needs. Whether I use
> your method or my method is irrelevant to YAGNI.
I'm looking at the original post and I still can't seem to find
anything about locales in there. Locales only came into the thread
when you posted your function.
> Thank you, try again.
My solution stands as the best one, for memory usage and speed.
Please benchmark it so you will learn from this experience.
--
Greg Donald
http://destiney.com/
attached mail follows:
On Tue, 2007-05-22 at 17:13 -0500, Greg Donald wrote:
>
> My solution stands as the best one, for memory usage and speed.
> Please benchmark it so you will learn from this experience.
Yours is the least maintainable. I have nothing to learn from you that I
didn't learn in kindergarten.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> Yours is the least maintainable.
Hehe.. with 4 times as many lines of code and 160% more bytes of code overall?
> cat locale.php|grep -v ^$|wc -l
16
> cat simple.php|grep -v ^$|wc -l
4
> ls -lavh
-rw-r--r-- 1 destiney destiney 347B May 22 17:35 locale.php
-rw-r--r-- 1 destiney destiney 133B May 22 17:35 simple.php
Watch me switch this from English to Spanish:
#$days = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday' );
$days = array( 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves',
'Viernes', 'Sábado' );
Tada! That was the easiest maintenance programming ever.
> I have nothing to learn from you that I
> didn't learn in kindergarten.
They didn't teach PHP where I attended kindergarten. Is that a Canadian thing?
--
Greg Donald
http://destiney.com/
attached mail follows:
On Tue, 2007-05-22 at 17:54 -0500, Greg Donald wrote:
> On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > Yours is the least maintainable.
>
> Hehe.. with 4 times as many lines of code and 160% more bytes of code overall?
>
> > cat locale.php|grep -v ^$|wc -l
> 16
>
> > cat simple.php|grep -v ^$|wc -l
> 4
>
>
> > ls -lavh
> -rw-r--r-- 1 destiney destiney 347B May 22 17:35 locale.php
> -rw-r--r-- 1 destiney destiney 133B May 22 17:35 simple.php
>
>
> Watch me switch this from English to Spanish:
>
> #$days = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
> 'Thursday', 'Friday', 'Saturday' );
> $days = array( 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves',
> 'Viernes', 'Sábado' );
>
> Tada! That was the easiest maintenance programming ever.
Sure, but you need to do that whenever the locale changes. I don't need
to change anything for the weekday names to be portable across all
locales. And yes I know, as you pointed out, the OP didn't say anything
about locale *shrug*. IMHO your solution is still inferior... but I
guess you like it that way.
> > I have nothing to learn from you that I
> > didn't learn in kindergarten.
>
> They didn't teach PHP where I attended kindergarten. Is that a Canadian thing?
Exactly, and I'm not about to learn PHP from you now *lol*.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > They didn't teach PHP where I attended kindergarten. Is that a Canadian thing?
>
> Exactly, and I'm not about to learn PHP from you now *lol*.
Next time you should say so up front, I would have spotted you 10% on
the benchmarks.
--
Greg Donald
http://destiney.com/
attached mail follows:
Hi,
Wednesday, May 23, 2007, 2:46:38 AM, you wrote:
BD> How can I convert the numerical day of week to the string version?
BD> Example, if the day of the week is 1 I would like to print out 'Sunday'.
BD>
BD> Thanks,
BD> Dave
<?php
$day =2;
//for a Monday start
echo gmdate('l',($day + 3) * 24 * 60 * 60)."\n";
// for a Sunday start
echo gmdate('l',($day + 2) * 24 * 60 * 60)."\n";
--
regards,
Tom
attached mail follows:
On Tue, 2007-05-22 at 19:17 -0500, Greg Donald wrote:
> On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> > > They didn't teach PHP where I attended kindergarten. Is that a Canadian thing?
> >
> > Exactly, and I'm not about to learn PHP from you now *lol*.
>
> Next time you should say so up front, I would have spotted you 10% on
> the benchmarks.
*haha* :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Mom! Dad! Stop fighting!
= = = Original message = = =
On 5/22/07, Robert Cummings <robert
interjinn.com> wrote:
> Yours is the least maintainable.
Hehe.. with 4 times as many lines of code and 160% more bytes of code overall?
> cat locale.php|grep -v ^$|wc -l
16
> cat simple.php|grep -v ^$|wc -l
4
> ls -lavh
-rw-r--r-- 1 destiney destiney 347B May 22 17:35 locale.php
-rw-r--r-- 1 destiney destiney 133B May 22 17:35 simple.php
Watch me switch this from English to Spanish:
#$days = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday' );
$days = array( 'Domingo', 'Lunes', 'Martes', 'Mi~rcoles', 'Jueves',
'Viernes', 'S~bado' );
Tada! That was the easiest maintenance programming ever.
> I have nothing to learn from you that I
> didn't learn in kindergarten.
They didn't teach PHP where I attended kindergarten. Is that a Canadian thing?
--
Greg Donald
http://destiney.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
attached mail follows:
On Tue, 2007-05-22 at 21:13 -0400, tg-php
gryffyndevelopment.com wrote:
> Mom! Dad! Stop fighting!
In case anyone is wondering... I'm the Dad!! >:)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Em Terça 22 Maio 2007 22:39, Robert Cummings escreveu:
> On Tue, 2007-05-22 at 21:13 -0400, tg-php
gryffyndevelopment.com wrote:
> > Mom! Dad! Stop fighting!
>
> In case anyone is wondering... I'm the Dad!! >:)
>
Just read my sig... =)
Time to sleep... Good bye! =)
--
Davi Vidal
davividal
siscompar.com.br
davividal
gmail.com
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBGU5wK33UYOg0uzToRAk/wAKCCAmTjN+Fe2gOCGdKIPraLCpp9pACbB1Kw
Q3gZw8OdMTDrMFO6BWAfs/s=
=0Iab
-----END PGP SIGNATURE-----
attached mail follows:
I think what you need is simply something like this:
function get_day($int_day){
$arr_day_of_week = array('1'=>'Sunday', '2'=>'Monday', '3'=>'Tuesday',
'4'=>'Wednesday', '5'=>'Thurdsay', '6'=>'Friday', '7'=>'Saturday');
}
echo(get_day(1)); //will print Sunday
--
itoctopus - http://www.itoctopus.com
""Bosky, Dave"" <Dave.Bosky
htcinc.net> wrote in message
news:DE411005B957D442AE1A3D4C1ACDB55905E7D4CA
HTCEXCHANGE.htc.com...
How can I convert the numerical day of week to the string version?
Example, if the day of the week is 1 I would like to print out 'Sunday'.
Thanks,
Dave
**********************************************************************
HTC Disclaimer: The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
**********************************************************************
attached mail follows:
On 5/22/07, Myron Turner <turnermm02
shaw.ca> wrote:
>
> > On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
> >
> >> I'm looking for a piece of software or coding that will let me post a
> >> form
> >> to another URL, accept the response, search it for a specific
> >> "success"
> >> string and then let me continue processing the rest of my program.
> >>
> >
> > http://php.net/curl
> >
> >
> >> I want to accept queries on behalf of my supplier, forward it to them
> >> behind
> >> the scenes, accept their response and display it within my website.
> >>
> >> Has anyone had any experience with this? Is there a simple, basic
> >> utility
> >> to let me do this?
> >>
> >> I was kind of hoping I could avoid developing it myself.
> >>
> As I understand this, you want to create a web page of your own which
> accepts requests for customers who are going to order products from your
> supplier. You want to have a form on your page which accepts their
> requests, then forward the form data on to your supplier's web site,
> where presumably it will be processed. Then you want to retrieve the
> response from your supplier's page, and display the result on your own
> web page. You suggest that the response string for "success" is
> relatively stable and that this string is this what you want to search
> for in the response.
>
> This doesn't sound like a very complicated problem. You can do this
> either using Ajax or not. The basic solution is the same. You have a
> script on the server which accepts the form data from your page and
> re-sends it to the supplier's site. If your supplier's site accepts
> form data using GET, then you can simply create a url with the form data
> attached in a query string:
>
> http://my.supplier.com?fdata_1=data1&fdata_2=data2
>
> Send this url to your suppler using file_get_contents:
>
> $return_string =
> file_get_contents("http://my.supplier.com?fdata_1=data1&fdata_2=data2");
>
> This will return the html file as a string which you can then parse with
> preg_match() for the 'success' string.
>
> The problem is more involved if your supplier doesn't accept GET but
> only accepts POST. Then you have to use either curl or fsockopen to
> post your data. I've tested the following fockopen script and it
> worked for me:
>
> <?php
> $fp = fsockopen("my.supplier.com", 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$errstr ($errno)<br />\n";
> } else {
> $out = "POST http://my.supplier.com/form_page.html / HTTP/1.1\r\n";
> $out .= "Host: my.supplier.com\r\n";
>
> $post = "form_data_1=data_1&formdata_2=data_2";
> $len = strlen($post);
> $post .= "\r\n";
>
> $out .="Content-Length: $len\r\n";
> $out .= "Connection: Close\r\n\r\n";
>
> $out .= $post;
>
> fwrite($fp, $out);
>
> $result= "";
> while (!feof($fp)) {
> $result .= fgets($fp, 128);
> }
> fclose($fp);
> echo $result;
>
>
> }
> ?>
>
> You have to adhere to the above sequence. The posted data comes last
> and it is preceded by a content-length header which tells the receiving
> server how long the posted data is. The returned result is the html
> page returned from your posted request.
>
It's a nice script, but you're way better off using cURL, you can
simply pass a PHP array as POST form data.
Tijnema
attached mail follows:
Tijnema wrote:
> On 5/22/07, Myron Turner <turnermm02
shaw.ca> wrote:
>>
>> > On Sat, May 19, 2007 10:22 pm, Shannon Whitty wrote:
>> >
>> >> I'm looking for a piece of software or coding that will let me post a
>> >> form
>> >> to another URL, accept the response, search it for a specific
>> >> "success"
>> >> string and then let me continue processing the rest of my program.
>> >>
>> >
>> > http://php.net/curl
>> >
>> >
>> >> I want to accept queries on behalf of my supplier, forward it to them
>> >> behind
>> >> the scenes, accept their response and display it within my website.
>> >>
>> >> Has anyone had any experience with this? Is there a simple, basic
>> >> utility
>> >> to let me do this?
>> >>
>> >> I was kind of hoping I could avoid developing it myself.
>> >>
>> As I understand this, you want to create a web page of your own which
>> accepts requests for customers who are going to order products from your
>> supplier. You want to have a form on your page which accepts their
>> requests, then forward the form data on to your supplier's web site,
>> where presumably it will be processed. Then you want to retrieve the
>> response from your supplier's page, and display the result on your own
>> web page. You suggest that the response string for "success" is
>> relatively stable and that this string is this what you want to search
>> for in the response.
>>
>> This doesn't sound like a very complicated problem. You can do this
>> either using Ajax or not. The basic solution is the same. You have a
>> script on the server which accepts the form data from your page and
>> re-sends it to the supplier's site. If your supplier's site accepts
>> form data using GET, then you can simply create a url with the form data
>> attached in a query string:
>>
>> http://my.supplier.com?fdata_1=data1&fdata_2=data2
>>
>> Send this url to your suppler using file_get_contents:
>>
>> $return_string =
>> file_get_contents("http://my.supplier.com?fdata_1=data1&fdata_2=data2");
>>
>> This will return the html file as a string which you can then parse with
>> preg_match() for the 'success' string.
>>
>> The problem is more involved if your supplier doesn't accept GET but
>> only accepts POST. Then you have to use either curl or fsockopen to
>> post your data. I've tested the following fockopen script and it
>> worked for me:
>>
>> <?php
>> $fp = fsockopen("my.supplier.com", 80, $errno, $errstr, 30);
>> if (!$fp) {
>> echo "$errstr ($errno)<br />\n";
>> } else {
>> $out = "POST http://my.supplier.com/form_page.html / HTTP/1.1\r\n";
>> $out .= "Host: my.supplier.com\r\n";
>>
>> $post = "form_data_1=data_1&formdata_2=data_2";
>> $len = strlen($post);
>> $post .= "\r\n";
>>
>> $out .="Content-Length: $len\r\n";
>> $out .= "Connection: Close\r\n\r\n";
>>
>> $out .= $post;
>>
>> fwrite($fp, $out);
>>
>> $result= "";
>> while (!feof($fp)) {
>> $result .= fgets($fp, 128);
>> }
>> fclose($fp);
>> echo $result;
>>
>>
>> }
>> ?>
>>
>> You have to adhere to the above sequence. The posted data comes last
>> and it is preceded by a content-length header which tells the receiving
>> server how long the posted data is. The returned result is the html
>> page returned from your posted request.
>>
>
> It's a nice script, but you're way better off using cURL, you can
> simply pass a PHP array as POST form data.
>
> Tijnema
>
Thanks. That's good to know. My experience with these kinds of things
is with Perl, with which I've done an awful lot of screen-scraping. But
I haven't had any actual practical experience with cURL. I've looked at
it, but that's all. Also, I was under the impression that cURL is an
extension which is not always installed, whereas fsockopen() is a
built-in. There is one server I sometimes use, a shared server, where it
isn't installed. The other servers I use are all independent machines.
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
attached mail follows:
Al wrote:
> Can I assume that all ftp_connect()s will make the current dir the
> DOC_ROOT?
First of all - what do you mean with DOC_ROOT? If it is the document
root (of what?!).
> If not, how can I insure the ftp root dir is the same as DOC_ROOT?
Define DOC_ROOT :)
> if you ftp_chdir() and it's already on the root, it posts an error.
Well if you tries to go back to the root - try to use ftp_cdup - but it
shouldn't be needed if you combine ftp_pwd and ftp_chdir
> ftp_pwd() simply returns "/", which simply says it's on its root, where
> ever that is.
If is (logical) the root of the ftp server. It can be whereever on the
server. It depends on the configuration of the FTP server ;)
--
Johan Holst Nielsen
Freelance PHP Developer - http://phpgeek.dk
attached mail follows:
What I ended up doing was to make a dir with ftp_mkdir(). Then test it with file_exists() to see if it is where I
expected. If not, I post a die() error msg and say "tech support required". Tech support can then figure out where the
ftp root dir is. and set a config file accordingly.
Thanks.......
Johan Holst Nielsen wrote:
> Al wrote:
>> Can I assume that all ftp_connect()s will make the current dir the
>> DOC_ROOT?
>
> First of all - what do you mean with DOC_ROOT? If it is the document
> root (of what?!).
>
>> If not, how can I insure the ftp root dir is the same as DOC_ROOT?
>
> Define DOC_ROOT :)
>
>> if you ftp_chdir() and it's already on the root, it posts an error.
>
> Well if you tries to go back to the root - try to use ftp_cdup - but it
> shouldn't be needed if you combine ftp_pwd and ftp_chdir
>
>> ftp_pwd() simply returns "/", which simply says it's on its root,
>> where ever that is.
>
> If is (logical) the root of the ftp server. It can be whereever on the
> server. It depends on the configuration of the FTP server ;)
>
attached mail follows:
Don Don wrote:
> Hi all, am trying to run a regular expression to a list of user entered data on some forms.
>
> I've creating what i think is a matching pattern for each category as shown below:
>
> function validateEntry($regularExpression, $fieldValue)
> {
> if(preg_match($regularExpression, $fieldValue))
> {
> return "true";
> }
> else
> {
> return "false";
> }
> }
>
this function sucks - it does nothing more than wrap preg_match and
returns strings instead of boolean values.
regexp's become hard very quickly - but for simple checks like your
doing your probably better off using the functions in the ctype
extension:
http://php.net/ctype
> i made a list of rules that are passed into the function above
>
> 1) [a-zA-Z][0-9] //allow any characters and numbers together anywhere within the text
> 2) [a-zA-Z] //allow only any charaters in the text
> 3) [0-9]{2} //allow only digits and they must be 2 in length
> 4) [a-zA-Z]{1} //allow only 1 character either uppercase or lowercase
>
>
> but each of these fail the validation when data is entered appropriately , seems iam getting something wrong.
how exactly do you define these regexps? seems like your forgetting to add a start/end delimiting
character to the regexp strings (as others have pointed out).
>
>
> Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 hot CTA = Join Yahoo!'s user panel
attached mail follows:
Ok, somehow I did this again (posted to pear-general instead of
php-general). pear-general and php-general look alike...
Thank everyone for their suggestion. I would like to see a __static()
version of __call(), but this is the wrong place to bring that feature
request up.
To answer Greg Beaver's observations, I would prefer to use static instances
in this case, to save myself the trouble (and overhead) of instantiating a
new object while developing classes. The utility is meant to provide unit
testing for individual classes or libraries, that can then be extended to a
specific class or library, and abstract the actually is_type() testing to
another class. It's a somewhat specific implementation meant more for unit
testing.
Below is the code I decided to implement (with a test below it to
demonstrate):
<code>
<?php
if (!class_exists('TypeAssert')) {
class TypeAssert {
public static $a;
public static $assert;
private static $types = array(
'array','bool','float','integer','null','numeric',
'object','resource','scalar','string'
);
function __construct() {
self::$assert =& self::$a;
}
public static function __call($method,$arguments) {
$obj = self::assertStandardTypes($arguments[0]);
return $obj->$method;
}
public static function assertStandardTypes($para) {
$r = TypeAssert::getTypesObject();
foreach ($r as $type=>$v) {
$func = "is_".strtolower($type);
if (function_exists($func) === true) {
if ($func($para) === true) {
$r->$type = true;
} else {
$r->$type = false;
}
}
}
return $r;
}
public static function getTypesObject() {
$obj = (object) '';
for ($i = 0; $i < count(self::$types); $i++) {
$obj->{self::$types[$i]} = (bool) false;
}
return $obj;
}
}
}
TypeAssert::$a = new TypeAssert();
echo("<pre>\n");
switch($_GET['type']) {
case 'int':
$test = 100;
$_test = 100;
break;
case 'float':
$test = 100.001;
$_test = 100.001;
break;
case 'null':
$test = null;
$_test = 'null';
break;
case 'object':
$test = TypeAssert::$a;
$_test = '[object]';
break;
default:
$test = 'string';
$_test = 'string';
break;
}
foreach (TypeAssert::getTypesObject() as $type => $v) {
echo("<div>is_<b style=\"color: #00a;\">$type</b>(<b>$_test</b>) === ".
(TypeAssert::$assert->$type($test)?
'<b style="color: #0a0;">true</b>':
'<b style="color: #a00;">false</b>').
"</div>\n"
);
}
echo("</pre>\n");
?>
</code>
Thanks!
On 5/22/07, Jared Farrish <farrishj
gmail.com> wrote:
>
> Thank everyone for their suggestion. I would like to see a __static()
> version of __call(), but this is the wrong place to bring that feature
> request up.
>
> To answer Greg Beaver's observations, I would prefer to use static
> instances in this case, to save myself the trouble (and overhead) of
> instantiating a new object while developing classes. The utility is meant to
> provide unit testing for individual classes or libraries, that can then be
> extended to a specific class or library, and abstract the actually is_type()
> testing to another class. It's a somewhat specific implementation meant more
> for unit testing.
>
> Below is the code I decided to implement (with a test below it to
> demonstrate):
>
> <code>
> <?php
> if (!class_exists('TypeAssert')) {
> class TypeAssert {
> public static $a;
> public static $assert;
> private static $types = array(
> 'array','bool','float','integer','null','numeric',
> 'object','resource','scalar','string'
> );
> function __construct() {
> self::$assert =& self::$a;
> }
> public static function __call($method,$arguments) {
> $obj = self::assertStandardTypes($arguments[0]);
> return $obj->$method;
> }
> public static function assertStandardTypes($para) {
> $r = TypeAssert::getTypesObject();
> foreach ($r as $type=>$v) {
> $func = "is_".strtolower($type);
> if (function_exists($func) === true) {
> if ($func($para) === true) {
> $r->$type = true;
> } else {
> $r->$type = false;
> }
> }
> }
> return $r;
> }
> public static function getTypesObject() {
> $obj = (object) '';
> for ($i = 0; $i < count(self::$types); $i++) {
> $obj->{self::$types[$i]} = (bool) false;
> }
> return $obj;
> }
> }
> }
> TypeAssert::$a = new TypeAssert();
> echo("<pre>\n");
> switch($_GET['type']) {
> case 'int':
> $test = 100;
> $_test = 100;
> break;
> case 'float':
> $test = 100.001;
> $_test = 100.001;
> break;
> case 'null':
> $test = null;
> $_test = 'null';
> break;
> case 'object':
> $test = TypeAssert::$a;
> $_test = '[object]';
> break;
> default:
> $test = 'string';
> $_test = 'string';
> break;
> }
> foreach (TypeAssert::getTypesObject() as $type => $v) {
> echo("<div>is_<b style=\"color: #00a;\">$type</b>(<b>$_test</b>) ===
> ".
> (TypeAssert::$assert->$type($test)?
> '<b style="color: #0a0;">true</b>':
> '<b style="color: #a00;">false</b>').
> "</div>\n"
> );
> }
> echo("</pre>\n");
> ?>
> </code>
>
> Thanks!
>
> --
> Jared Farrish
> Intermediate Web Developer
> Denton, Tx
>
> Abraham Maslow: "If the only tool you have is a hammer, you tend to see
> every problem as a nail." $$
>
--
Jared Farrish
Intermediate Web Developer
Denton, Tx
Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$
attached mail follows:
Hello again;
In my frustration and laziness (tired of probing around to solve syntax
errors that are not obvious)
I have encountered the following error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
<path removed> groups_proc.php on line 585
The two lines immediately proceeding the line referenced by the error
and line 585 follow:
line 583: $pending_to = str_replace("//\$requests_to[] = ' ';",
"\$requests_to[$list_length] = '$input[4]';\n//\$requests_to[] = ' ';",
$pending_to);
line 584: $pending_to = str_replace("//\$r_group_to[] = ' ';",
"\$r_group_to[$list_length] = '$input[3]';\n//\$r_group_to[] = ' ';",
$pending_to);
line 585: $pending_to = str_replace("//\$r_status_to[] = ' ';",
"\$r_status_to[$list_length] = 'pend';\n//\$r_status_to[] = ' ';",
$pending_to); <- error reference line
I can't see it. The only problem I would imagine, is that $list_length
is an integer and not a string. But if that was what is being
complained about,
why didn't the error occur at line 583?
(
I am trying to add array items to a php file by writing them to it.
$list_length is a variable declared in the file to keep track of what
index to assign
to new array items. It is incremented when an item is added. The
reason is that there are 3 arrays and all have to correlated item for
item.
Yes there probably is a better way but this is what I have to deal with
at present.
)
Thanks for help in advance
Jeff K
attached mail follows:
Hello again;
(Blush);
I was looking at the wrong line. Somehow the line numbers changed on me
and the error was actually at a suspect line that I had changed. But the
file that was giving the error was a file that was not updated.
Now it works,
I was trying to do $list_length -1 in the middle of an interpolated
string
like; "string".$list_length -1."string".
I had to write this message as soon as I saw the error to spare those
who would read and not be able to see it either.
Thanks again;
JK
attached mail follows:
Hope this helps:
http://forum.mamboserver.com/showthread.php?t=55&page=6
--
itoctopus - http://www.itoctopus.com
"Sn!per" <sniper
home.net.my> wrote in message
news:1179806087.46526987c82bc
mail.home.net.my...
> Am currently running Plesk 8.0.1 . A php script with phpinfo() will give:
> ...
> ...
> '--with-kerberos' '--with-ldap=shared' '--with-mysql=shared,
> ...
> ...
>
> But am not able to locate the LDAP section that normally looks like:
>
> LDAP Support enabled
> RCS Version $Id: ldap.c,v 1.130.2.11 2005/01/19 00:28:49 bigtoy Exp $
> Total Links 0/unlimited
> API Version 2004
> Vendor Name OpenLDAP
> Vendor Version 20025
>
> As such, when running a script that uses any LDAP functions, I will get
> error msgs like:
> Fatal error: Call to undefined function: ldap_connect() ...
>
> Any idea how I can go about solving this issue? Please advise. TIA
>
> --
> roger
>
>
>
> ---------------------------------------------------
> Sign Up for free Email at http://ureg.home.net.my/
> ---------------------------------------------------
attached mail follows:
ok, I read the whole thread and it seems it went absolutely nowhere.
Sorry...
--
itoctopus - http://www.itoctopus.com
""itoctopus"" <newsgroup
itoctopus.com> wrote in message
news:65.0A.18863.B5DA3564
pb1.pair.com...
> Hope this helps:
> http://forum.mamboserver.com/showthread.php?t=55&page=6
>
> --
> itoctopus - http://www.itoctopus.com
> "Sn!per" <sniper
home.net.my> wrote in message
> news:1179806087.46526987c82bc
mail.home.net.my...
>> Am currently running Plesk 8.0.1 . A php script with phpinfo() will give:
>> ...
>> ...
>> '--with-kerberos' '--with-ldap=shared' '--with-mysql=shared,
>> ...
>> ...
>>
>> But am not able to locate the LDAP section that normally looks like:
>>
>> LDAP Support enabled
>> RCS Version $Id: ldap.c,v 1.130.2.11 2005/01/19 00:28:49 bigtoy Exp $
>> Total Links 0/unlimited
>> API Version 2004
>> Vendor Name OpenLDAP
>> Vendor Version 20025
>>
>> As such, when running a script that uses any LDAP functions, I will get
>> error msgs like:
>> Fatal error: Call to undefined function: ldap_connect() ...
>>
>> Any idea how I can go about solving this issue? Please advise. TIA
>>
>> --
>> roger
>>
>>
>>
>> ---------------------------------------------------
>> Sign Up for free Email at http://ureg.home.net.my/
>> ---------------------------------------------------
attached mail follows:
Dear all.
I have a script that is called by an AJAX popup. Now I use an image
file to get the path of an image for an <img> tag
eg:
<img border="0" id="middleImage" name="middleImage" src="<? echo
$getImageURL; ?>" >
the $getImageURL is composed as follows:
$getImageURL = "getImage.php?imageid=".
$imageID."&height=275&width=375&quality=65";
However when I look at the URL that gets sent its as follows:
getImage.php?imageid=10&height=275&width=375&quality=65
Which is obviously incorrect.
So I tried:
$getImageURL = html_entity_decode("getImage.php?imageid=".
$imageID."&height=275&width=375&quality=65");
But that doesn't seem to be working. . . As the html_entity_decode
should the & sign to the & sign?
Am I going in the right direction or can anyone else let me know if
there is something I am missing or should be doing?
Thanks in advance.
--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------
*Telephone:* +27 (021) 469 1052
*Mobile:* +27 (0) 72 441 3355
*Fax:* +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* angelo
zlogic.co.za <mailto:angelo
zlogic.co.za>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]