php-general Digest 1 Apr 2011 08:28:26 -0000 Issue 7253

2011-04-01 Thread php-general-digest-help

php-general Digest 1 Apr 2011 08:28:26 - Issue 7253

Topics (messages 312157 through 312186):

If Statements Array and Notice Undefined Index
312157 by: Nicholas Cooper
312158 by: Stuart Dallas
312161 by: Nicholas Cooper
312184 by: Al

Re: session_start() may take 5 seconds :(
312159 by: Tolas Anon
312160 by: Tolas Anon

neubie seeking answers
312162 by: Kirk Bailey
312163 by: Richard Quadling
312164 by: Stuart Dallas
312165 by: Steve Staples
312166 by: Steve Staples
312185 by: Kirk Bailey
312186 by: Stuart Dallas

Closing Session
312167 by: Ethan Rosenberg
312168 by: Jay Blanchard
312169 by: Daniel Brown
312170 by: Ethan Rosenberg
312171 by: Ashley Sheridan
312173 by: Daniel Brown
312175 by: Ethan Rosenberg
312176 by: Daniel Brown
312177 by: Ashley Sheridan
312178 by: Steve Staples
312179 by: Stuart Dallas
312181 by: Ethan Rosenberg
312182 by: Ethan Rosenberg

Re: is there a static constructor?
312172 by: Admin

Re: session variable problem
312174 by: markb

PHP 5.2.x with MySQL 5.5.x
312180 by: Andre Matos

Re: Sessions - More Info
312183 by: Boers Steven

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


--
---BeginMessage---
Good day,

I have three arrays A, B and C. Anyone of them might not have the 'id' key
set which will give the Notice Undefined index: id.

I just wanted to know what the correct approach to this problem would be;
without making the code overly complicated to read by introducing a number
of if isset statements.

if  ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {

}

I have notices switched off, but I want to know the right way to do this.
 There's probably a number of different right ways to solve this, how would
you do it?

Best Regards,

Nicholas
---End Message---
---BeginMessage---
On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
Good day,
 
 I have three arrays A, B and C. Anyone of them might not have the 'id' key
 set which will give the Notice Undefined index: id.
 
 I just wanted to know what the correct approach to this problem would be;
 without making the code overly complicated to read by introducing a number
 of if isset statements.
 
 if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
 
 }
 
 I have notices switched off, but I want to know the right way to do this.
  There's probably a number of different right ways to solve this, how would
 you do it?

This is how I handle this...

// Define this function somewhere global
function ifsetor($array, $key, $default = null)
{
return (isset($array[$key]) ? $array[$key] : $default);
}

if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC, 'id') 
== ifsetor($arrayB, 'id'))...

If you need to avoid a match if neither $arrayA nor $arrayB have an id you 
simply pass a different default for each one.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd

http://3ft9.com/



---End Message---
---BeginMessage---
On 31 March 2011 15:53, Stuart Dallas stu...@3ft9.com wrote:

 On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
 Good day,
 
  I have three arrays A, B and C. Anyone of them might not have the 'id'
 key
  set which will give the Notice Undefined index: id.
 
  I just wanted to know what the correct approach to this problem would be;
  without making the code overly complicated to read by introducing a
 number
  of if isset statements.
 
  if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
 
  }
 
  I have notices switched off, but I want to know the right way to do this.
   There's probably a number of different right ways to solve this, how
 would
  you do it?

 This is how I handle this...

 // Define this function somewhere global
 function ifsetor($array, $key, $default = null)
 {
 return (isset($array[$key]) ? $array[$key] : $default);
 }

 if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC,
 'id') == ifsetor($arrayB, 'id'))...

 If you need to avoid a match if neither $arrayA nor $arrayB have an id you
 simply pass a different default for each one.

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd

 http://3ft9.com/




Thank you, that is quiet an elegant solution.

Very little additional code excluding the function and it could also easily
be extended for multi dimensional arrays by changing $key to an array and
looping through each index in turn.

Best Regards

Nicholas
---End Message---
---BeginMessage---



On 3/31/2011 10:45 AM, Nicholas Cooper wrote:

Good day,

I have three arrays A, B and C. 

Re: [PHP] neubie seeking answers

2011-04-01 Thread Stuart Dallas
On Friday, 1 April 2011 at 03:31, Kirk Bailey wrote:
PERFECT SIMPLE SOLUTION. THANK YOU!

As Richard noted there is a constant called __DIR__ which is equivalent to 
dirname(__FILE__) so basename(__DIR__) will give you what you want and saves a 
few cycles.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


 On 3/31/2011 12:34 PM, Stuart Dallas wrote:
  On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
  I need to extract the name of the subdirectory a page lives in to
   use in the title for that page. This will be returned as a string to
   echo to the output stream. Now how the heck do I do that?!?
  $dir = basename(dirname(__FILE__));
  
  -Stuart
 
 -- 
 end
 
 Very Truly yours,
  - Kirk Bailey,
  Largo Florida
 
  kniht
  +-+
  | BOX |
  +-+
  think
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] neubie seeking answers

2011-04-01 Thread Richard Quadling
On 1 April 2011 03:31, Kirk Bailey kbai...@howlermonkey.net wrote:
 PERFECT SIMPLE SOLUTION. THANK YOU!

 On 3/31/2011 12:34 PM, Stuart Dallas wrote:

 On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
 I need to extract the name of the subdirectory a page lives in to

 use in the title for that page. This will be returned as a string to
 echo to the output stream. Now how the heck do I do that?!?

 $dir = basename(dirname(__FILE__));

 -Stuart

Are my posts invisible?



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Closing Session

2011-04-01 Thread Richard Quadling
On 31 March 2011 21:40, Ethan Rosenberg eth...@earthlink.net wrote:
 At 02:12 PM 3/31/2011, Ashley Sheridan wrote:

 On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:

  At 01:30 PM 3/31/2011, Daniel Brown wrote:
  On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg eth...@earthlink.net
   wrote:
Dear List -
   
Thanks for your help.
   
How do I close a session form the terminal?  I need the ability to
do this
for debugging.  I often have more than one session open at the
   same time, so
creating a program with session_start() and session_unset() or
session_destoy() would probably not work.
  
       Can you rephrase the question, Ethan, or give more details?  From
  the way it sounds, you're concerned that destroying a session will
  have implications for other sessions as well, which is not the case
  (unless all sessions are shared).  For example, if you have Chrome,
  Firefox, and Internet Exploder all active, the sessions should be
  different, if even from the very same computer.  However, multiple
  tabs in the same browser will generally be the same session (unless
  it's something like Chrome's Incognito feature).
  
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  http://www.php.net/
  =
  Thanks.
 
  Multiple tabs in the same browser will generally be the same session.
 
  That is what I have.
 
  Ethan
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php


 If they're all in the same browser, then what distinguishes them from
 one another? If you could use that and add some sort of array in the
 session with entries bearing to what tabs you have open then you could
 use that to 'close' sessions. Why do you need multiple tabs open to the
 same site anyway, maybe if you explained what it is you're trying to
 achieve, we might help with a better way?

 --
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

 
 Ash -

 I can be working on more than one program simultaneously and have one tab
 open w/ program A and another w/ program B.  The site in reference is
 http://localhost;

 I hope this helps.

 Ethan


 MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



You can use a path element in the session cookie ...

session_cookie(60, '/appA', 'localhost'); // For http://localhost/appA
session_cookie(60, '/appB', 'localhost'); // For http://localhost/appB

maybe.

I don't use localhost.

Instead, I create vhosts on the web server and use DNS (or you can use
entries in your HOSTs file).

That way I can have separate sites, each with their own domain name
and allow for multiple sub-domains (dev, test and www for live).


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Closing Session

2011-04-01 Thread Richard Quadling
On 31 March 2011 23:16, Ethan Rosenberg eth...@earthlink.net wrote:

 snip
        127.0.0.1 localhost development subdomain.development

    Don't worry about it being an FQDN.  Prior to checking with the
 router or DNS servers, all modern systems check the hosts file.  Then
 just add a reference to each in your Apache configuration file and
 restart Apache.  Boom.  Done.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 =

 Dan -

 I'm a newbie...

 1] What should the line in the Apache configuration file be? Just to be
 sure, the file is: /etc/apache2/apache2.conf, correct?

I don't use Apache, so hopefully someone else can answer this.

 2] Back to the original questionhow do I kill a session from the
 terminal?

You can't.

But if you can find the session ID, you could manually delete the
session file - if you are using files for your sessions.

If you are using a DB, then you'd have to write a script to kill it.

Another option would be to create a killsession.php script ...

?php
session_start();
session_destroy();
session_close();
?

I think that'll do the job.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Closing Session

2011-04-01 Thread Ford, Mike
 -Original Message-
 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: 31 March 2011 21:40
 
 I can be working on more than one program simultaneously and have
 one
 tab open w/ program A and another w/ program B.  The site in
 reference is http://localhost;

Do these programs share any part of their session information? If not,
then how about using session_name() to differentiate - that way, each
one stores its session_id in its own cookie and will have its own
session.

On the other hand, if they do share parts of the session information
(such as user id, say), the suggestion of using sub-arrays per
application sounds good to me.

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Closing Session - Apache

2011-04-01 Thread Ethan Rosenberg

At 05:04 AM 4/1/2011, Richard Quadling wrote:

On 31 March 2011 23:16, Ethan Rosenberg eth...@earthlink.net wrote:

 snip
 Dan -

 I'm a newbie...

 1] What should the line in the Apache configuration file be? Just to be
 sure, the file is: /etc/apache2/apache2.conf, correct?


--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY


Thanks.

To set up subdomains w/ Apache..
127.0.0.1 localhost development subdomain.development

 Don't worry about it being an FQDN.  Prior to checking with the
 router or DNS servers, all modern systems check the hosts file.  Then
 just add a reference to each in your Apache configuration file and
 restart Apache.  Boom.  Done

Can someone help w/ this:

What should the line in the Apache configuration file be? Just to be
sure, the file is: /etc/apache2/apache2.conf, correct?

Ethan 




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: session variable problem

2011-04-01 Thread markb

On 3/25/2011 12:09 PM, markb wrote:

Very rusty with PHP.
We moved our web site to a new hosting service (godaddy). PHP changed
from 4x to 5.2.17.
I can no longer change $_SESSION variables after the first use.
First call to form - start session create variables
Second call - can read variables, change existing ones (but they do not
persist to next call) - cannot create new variable without an error

Using $_SESSION['varname'] always
session.auto_start off
register_globals off
session.use_only_cookies off

I assume this is setting difference but I can't seem to find it.





Also had another issue in converting to PHP 5.  I had been passing 
$_SESSION variable to functions.  For some reason this was wiping out 
the values after each call.


--
Mark B

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-WIN] Re: [PHP] Which versions of Apache will PHP 5.3.6 work with??

2011-04-01 Thread Santosh gunat
Hi,

I am in a big problem,

My manager gave a task,
He want a PHP scrip which will check if the remote machines are Powered on
and are running.
He want this to be done using eclipse.

He also want a log in a HTML or text file that which remote machine is
running and which remote machine is down/powered off for each machine

Can you help me.

Thanks in advance ,

Santosh Gunat


[PHP] How to check if remote machines are running using PHP and Eclipse-Require Urgent Help

2011-04-01 Thread Santosh gunat
Hi,

I am in a big problem,

My manager gave a task,
He want a PHP scrip which will check if the remote machines are Powered on
and are running.
He want this to be done using eclipse.

He also want a log in a HTML or text file that which remote machine is
running and which remote machine is down/powered off for each machine

Can you help me.

If there is another way ,to check automatically that will also be fine.But
we want a automatic script checking and saving logs for the same.

Thanks in advance ,

Santosh Gunat


Re: [PHP] newbie - function is undefined

2011-04-01 Thread Micky Hulse
Maybe try:

echo 'getText(p1)';

I think that should work.

Good luck.

Cheers,
Micky

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner
Thanks - now I see.  the message means that it can't find a php function 
called getText.  Doh! 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Looking for Tool to read JSON format

2011-04-01 Thread Michelle Konzack
Hello *,

curently I am coding on my new Intranet Interface, but  some  teleguided
servers return only JSON or YAML files.

Can someone tell me, how to import JSON files in PHP 5/6?

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsystems@tdnet France EURL   itsystems@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

http://www.itsystems.tamay-dogan.net/  http://www.flexray4linux.org/
http://www.debian.tamay-dogan.net/ http://www.can4linux.org/

Jabber linux4miche...@jabber.ccc.de

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


Re: [PHP] Looking for Tool to read JSON format

2011-04-01 Thread Simon J Welsh
On 2/04/2011, at 10:19 AM, Michelle Konzack wrote:

 Hello *,
 
 curently I am coding on my new Intranet Interface, but  some  teleguided
 servers return only JSON or YAML files.
 
 Can someone tell me, how to import JSON files in PHP 5/6?
 
 Thanks, Greetings and nice Day/Evening
Michelle Konzack

json_decode(file_get_contents('http://domain/file.json'));

If you need to do a POST rather than a GET, use curl and pass the output from 
curl_exec() to json_decode().

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner

function. Try something like:
...
echo 'heaading contains: scriptgetText(h2)/script';
...

I tried it - no better. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Looking for Tool to read JSON format

2011-04-01 Thread Me

http://www.php.net/manual/en/book.json.php

Sent via DROID on Verizon Wireless

-Original message-
From: Simon J Welsh si...@welsh.co.nz
To: Michelle Konzack linux4miche...@tamay-dogan.net
Cc: PHP - General php-general@lists.php.net
Sent: Fri, Apr 1, 2011 21:23:22 GMT+00:00
Subject: Re: [PHP] Looking for Tool to read JSON format

On 2/04/2011, at 10:19 AM, Michelle Konzack wrote:


Hello *,

curently I am coding on my new Intranet Interface, but  some  teleguided
servers return only JSON or YAML files.

Can someone tell me, how to import JSON files in PHP 5/6?

Thanks, Greetings and nice Day/Evening
   Michelle Konzack


json_decode(file_get_contents('http://domain/file.json'));

If you need to do a POST rather than a GET, use curl and pass the output  
from curl_exec() to json_decode().


---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never,  
ever crashes!


http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newbie - function is undefined

2011-04-01 Thread Richard S. Crawford
On Fri, Apr 1, 2011 at 2:32 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


 function. Try something like:
 ...
 echo 'heaading contains: scriptgetText(h2)/script';
 ...

 I tried it - no better.


Did you still get the function undefined error?

-- 
Sláinte,
Richard S. Crawford (rich...@underpope.com)
http://www.underpope.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)


Re: [PHP] newbie - function is undefined

2011-04-01 Thread Alex Nikitin
JavaScript is a browser-side language, browsers have cache, cache sticks
around, meaning that you can tell the browser to cache the JS file and not
download it from the server (every time) if its being included on the
browser end (which js is). All means faster page load times post initial
load, and less bandwidth. If you include the JS file with php, every time
you request the page the javascript will be pulled from your hard drive by
php and sent back as a part of the server response (your end web page).


~ Alex



On Fri, Apr 1, 2011 at 5:32 PM, Jim Giner jim.gi...@albanyhandball.comwrote:


 function. Try something like:
 ...
 echo 'heaading contains: scriptgetText(h2)/script';
 ...

 I tried it - no better.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner
And the way to do this is? 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Stuart Dallas
On Friday, 1 April 2011 at 22:43, Alex Nikitin wrote:
JavaScript is a browser-side language, browsers have cache, cache sticks
 around, meaning that you can tell the browser to cache the JS file and not
 download it from the server (every time) if its being included on the
 browser end (which js is). All means faster page load times post initial
 load, and less bandwidth. If you include the JS file with php, every time
 you request the page the javascript will be pulled from your hard drive by
 php and sent back as a part of the server response (your end web page).

I think given the nature and level of the original question, talking about the 
browser cache is only likely to confuse the poor chap.

Jim: Ignore the browser cache for now and focus on learning the difference 
between javascript and PHP and which one should be used in what situations.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/



 On Fri, Apr 1, 2011 at 5:32 PM, Jim Giner jim.gi...@albanyhandball.comwrote:
 
  
  function. Try something like:
  ...
  echo 'heaading contains: scriptgetText(h2)/script';
  ...
  
  I tried it - no better.
  
  
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to check if remote machines are running using PHP and Eclipse-Require Urgent Help

2011-04-01 Thread Louis Huppenbauer
You could just periodically ping those remote machines with a
system()-call, and then write the result to a file.

2011/4/1 Santosh gunat santoshgu...@gmail.com:
 Hi,

 I am in a big problem,

 My manager gave a task,
 He want a PHP scrip which will check if the remote machines are Powered on
 and are running.
 He want this to be done using eclipse.

 He also want a log in a HTML or text file that which remote machine is
 running and which remote machine is down/powered off for each machine

 Can you help me.

 If there is another way ,to check automatically that will also be fine.But
 we want a automatic script checking and saving logs for the same.

 Thanks in advance ,

 Santosh Gunat


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to check if remote machines are running using PHP and Eclipse-Require Urgent Help

2011-04-01 Thread Jim Giner
your boss is asking you to write something in PHP, but it sounds to me like 
you are not very knowledgable in it, or even in creating a text file.  Why 
is he doing this? 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to check if remote machines are running using PHP and Eclipse-Require Urgent Help

2011-04-01 Thread Stuart Dallas
On Friday, 1 April 2011 at 17:07, Santosh gunat wrote:
Hi,
 
 I am in a big problem,
 
 My manager gave a task,
 He want a PHP scrip which will check if the remote machines are Powered on
 and are running.
 He want this to be done using eclipse.
 
 He also want a log in a HTML or text file that which remote machine is
 running and which remote machine is down/powered off for each machine
 
 Can you help me.
 
 If there is another way ,to check automatically that will also be fine.But
 we want a automatic script checking and saving logs for the same.

Sounds like you want a service such as http://pingdom.com/ or one of the 
hundreds of other services out there that do this. IMO writing your own script 
to do this is a waste of resources.

Also, give your boss a slap. Why is he specifying what editor you use to write 
a PHP script? I really don't understand most management types!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd

http://3ft9.com/




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] date problem

2011-04-01 Thread Dan Dan
I removed the day (1 before the March), but its still giving the same
result, i.e. different days of month with and without the 'first'. Any
further help ?

print first Tuesday :.date(d-m-Y H:i:s,strtotime('March 2011
Tuesday')).\n;
print first: .date(d-m-Y H:i:s,strtotime('March 2011 first
Tuesday')).\n;
print second: .date(d-m-Y H:i:s,strtotime('March 2011 second
Tuesday')).\n;
print third: .date(d-m-Y H:i:s,strtotime('March 2011 third
Tuesday')).\n;
print fourth: .date(d-m-Y H:i:s,strtotime('March 2011 fourth
Tuesday')).\n;

first Tuesday :01-03-2011 00:00:00
first: 08-03-2011 00:00:00
second: 15-03-2011 00:00:00
third: 22-03-2011 00:00:00
fourth: 29-03-2011 00:00:00

Thanks
-dani



On Fri, Apr 1, 2011 at 9:37 AM, Daniel Brown danbr...@php.net wrote:

 On Fri, Apr 1, 2011 at 12:35, Dan Dan dani.mani...@gmail.com wrote:
  Hi Folks,
 
  I am trying to get the day of month for a particular day of week (e.g.
  Tuesday) for the first, second, third, fourth week in a month. The code i
  have seems issues in March, but works e.g. in April:
 
  print date(d-m-Y H:i:s,strtotime('1 March 2011 Tuesday'));
  01-03-2011 00:00:00
 
  print date(d-m-Y H:i:s,strtotime('1 March 2011 first Tuesday'));
  08-03-2011 00:00:00
 
  While in April, I have
 
  print date(d-m-Y H:i:s,strtotime('1 April 2011 Tuesday'));
  05-04-2011 00:00:00
 
  print date(d-m-Y H:i:s,strtotime('1 April 2011 first Tuesday'));
  05-04-2011 00:00:00
 
  Could someone help whats wrong with the technique i am trying to find
 that
  day of month. Is there any better way ?

 Because you're combining the date with the day of the week.  It so
 happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
  Pick one or the other, not both.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/