php-general Digest 25 Oct 2012 10:32:45 -0000 Issue 8021

2012-10-25 Thread php-general-digest-help

php-general Digest 25 Oct 2012 10:32:45 - Issue 8021

Topics (messages 319584 through 319587):

Re: Array help.
319584 by: Samuel Lopes Grigolato
319585 by: Paul Halliday
319586 by: Ford, Mike

Re: Help using PHP 5.3.3 mail() with Apache James
319587 by: Maciek Sokolewicz

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---
Could you try changing this:

if($groupTest != FALSE) {

to this:

if($groupTest !== FALSE) {

?

-Mensagem original-
De: Paul Halliday [mailto:paul.halli...@gmail.com] 
Enviada em: quarta-feira, 24 de outubro de 2012 15:38
Para: PHP-General
Assunto: [PHP] Array help.

I am processing v4IP's and what I want to do is a prefix substitution if the
3rd octet matches a predefined list $groupMappings. I went down this  path
and it isn't working as expected. Drawing a blank on this one. Why does 40
miss the comparison?

$hostname = Z;
$ips = array('10.1.40.1','10.1.41.1','10.1.1.1','10.1.40.1','10.9.1.1');

foreach ($ips as $ip) {

$groupMappings = array('40' ='A','41' ='B','1' ='C');

$ocTest = explode(., $ip);
$groupKeys = array_keys($groupMappings);
$groupTest = array_search($ocTest[2], $groupKeys);

if($groupTest != FALSE) {
$hostGroup = $groupMappings[$groupKeys[$groupTest]];
echo Hit! $ip : $hostname : $hostGroup\n;
} else {
$hostGroup = substr($hostname, 0,2);
echo Miss! $ip : $hostname : $hostGroup\n;
}
}

Miss! 10.1.40.1 : Z : Z
Hit! 10.1.41.1 : Z : B
Hit! 10.1.1.1 : Z : C
Miss! 10.1.40.1 : Z : Z
Hit! 10.9.1.1 : Z : C

Thanks!

--
Paul Halliday
http://www.pintumbler.org/

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


---End Message---
---BeginMessage---
On Wed, Oct 24, 2012 at 2:40 PM, Samuel Lopes Grigolato
samuel.grigol...@gmail.com wrote:
 Could you try changing this:

 if($groupTest != FALSE) {

 to this:

 if($groupTest !== FALSE) {

 ?

Hah. Perfect! Thanks.


 -Mensagem original-
 De: Paul Halliday [mailto:paul.halli...@gmail.com]
 Enviada em: quarta-feira, 24 de outubro de 2012 15:38
 Para: PHP-General
 Assunto: [PHP] Array help.

 I am processing v4IP's and what I want to do is a prefix substitution if the
 3rd octet matches a predefined list $groupMappings. I went down this  path
 and it isn't working as expected. Drawing a blank on this one. Why does 40
 miss the comparison?

 $hostname = Z;
 $ips = array('10.1.40.1','10.1.41.1','10.1.1.1','10.1.40.1','10.9.1.1');

 foreach ($ips as $ip) {

 $groupMappings = array('40' ='A','41' ='B','1' ='C');

 $ocTest = explode(., $ip);
 $groupKeys = array_keys($groupMappings);
 $groupTest = array_search($ocTest[2], $groupKeys);

 if($groupTest != FALSE) {
 $hostGroup = $groupMappings[$groupKeys[$groupTest]];
 echo Hit! $ip : $hostname : $hostGroup\n;
 } else {
 $hostGroup = substr($hostname, 0,2);
 echo Miss! $ip : $hostname : $hostGroup\n;
 }
 }

 Miss! 10.1.40.1 : Z : Z
 Hit! 10.1.41.1 : Z : B
 Hit! 10.1.1.1 : Z : C
 Miss! 10.1.40.1 : Z : Z
 Hit! 10.9.1.1 : Z : C

 Thanks!

 --
 Paul Halliday
 http://www.pintumbler.org/

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


---End Message---
---BeginMessage---
 From: Paul Halliday [paul.halli...@gmail.com]
 Sent: 24 October 2012 18:38
 To: PHP-General
 Subject: [PHP] Array help.
 
 $groupMappings = array('40' ='A','41' ='B','1' ='C');
 
 $ocTest = explode(., $ip);
 $groupKeys = array_keys($groupMappings);
 $groupTest = array_search($ocTest[2], $groupKeys);
 
 if($groupTest != FALSE) {

I think you're making a little bit of a meal of this. My initial thoughts
included pointing you at array_key_exists() (and, why on earth
have you got $ocTest[2] in quotes?), but then I realised if I were
writing this I'd probably just use isset(), thus:

   $ocTest = explode(., $ip);
   if (isset($groupMappings[$ocTest[2]])):
  // success
   else:
  // fail
   endif;

Hope this helps!


Cheers!

Mike

-- 
Mike Ford, Electronic Information Developer, Libraries and Learning Information
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS, LS1 3HE, United Kingdom
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730

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

On 23-10-2012 23:54, Steven Pogue wrote:

Dan,
I assume you meant to add a system() call into it...if so, here is what
was presented.

-rwxrwxrwx. 1 root root 3878 Sep  6 14:45 /opt/james-2.3.2/bin/sendmail.py
-rwxrwxrwx. 1 

php-general Digest 26 Oct 2012 01:16:02 -0000 Issue 8022

2012-10-25 Thread php-general-digest-help

php-general Digest 26 Oct 2012 01:16:02 - Issue 8022

Topics (messages 319588 through 319598):

Re: Help using PHP 5.3.3 mail() with Apache James
319588 by: tamouse mailing lists

PCRE Expression
319589 by: Volmar Machado
319590 by: Camille Hodoul

Date manipulation
319591 by: Ron Piggott
319592 by: Daniel Brown
319593 by: Marc Guay

select function
319594 by: Jeff Burcher
319595 by: Daniel Brown
319596 by: Stuart Dallas
319597 by: Ford, Mike

URGENT! Need help with command line for list all new/modified files within the 
last 24 hours
319598 by: lamp.afan.net

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---
On Thu, Oct 25, 2012 at 5:32 AM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
 On 23-10-2012 23:54, Steven Pogue wrote:

 Dan,
 I assume you meant to add a system() call into it...if so, here is what
 was presented.

 -rwxrwxrwx. 1 root root 3878 Sep  6 14:45 /opt/james-2.3.2/bin/sendmail.py
 -rwxrwxrwx. 1 root root 3878 Sep  6 14:45 /opt/james-2.3.2/bin/sendmail.py


 Steve

 Hey Steve,

 first of all: don't top-post.
 Secondly: no, he didn't. Dan used the backtick operator (`) which is the
 same as calling system on its parameter.

 ie:
 `ls -l`
 is equal to writing
 shell_exec('ls -l')

 ( http://www.php.net/manual/en/language.operators.execution.php )

I have lost the backtick operator so many times, I've stopped using
it, using shell_exec instead.
---End Message---
---BeginMessage---
Hi All,

 I have this expression :  '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)\}/s'
which grep all single property css like:

.chalala{
float:left;
}

.chalala{float:left;}

.chalala{
float:left;}

But I want to grep multiples properties like:


.chalala{
float:left;
float:right;
}

So I think that I need to repeat subgroup many times and put a '*'
after subgroup, like this:  '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\}/s'
but didn't work, how I can check if a subgroup repeat {0,} ?
---End Message---
---BeginMessage---

which pcre function do you use ?
\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\} seems to work on my regex tester.

Le 25/10/2012 18:51, Volmar Machado a écrit :

Hi All,

  I have this expression :  '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)\}/s'
which grep all single property css like:

.chalala{
float:left;
}

.chalala{float:left;}

.chalala{
float:left;}

But I want to grep multiples properties like:


.chalala{
float:left;
float:right;
}

So I think that I need to repeat subgroup many times and put a '*'
after subgroup, like this:  '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\}/s'
but didn't work, how I can check if a subgroup repeat {0,} ?



--
Camille Hodoul
http://camille-hodoul.com

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

Is it possible for PHP to accept the following as a date:

04:11:22 Aug 21, 2011 PDT

so I may output it as:

gmdate(‘Y-m-d H:i:s’)

- I want the time zone included

Ron


Ron Piggott



www.TheVerseOfTheDay.info 
---End Message---
---BeginMessage---
On Thu, Oct 25, 2012 at 3:06 PM, Ron Piggott
ron.pigg...@actsministries.org wrote:

 Is it possible for PHP to accept the following as a date:

 04:11:22 Aug 21, 2011 PDT

 so I may output it as:

 gmdate(‘Y-m-d H:i:s’)

 - I want the time zone included

Sure.

?php

$ds = strtotime('04:11:22 Aug 21, 2011 PDT');

echo gmdate('Y-m-d H:i:s',$ds);

?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/
---End Message---
---BeginMessage---
$time = strtotime('04:11:22 Aug 21, 2011 PDT');
echo date('Y-m-d H:i:s T', $time);

Marc
---End Message---
---BeginMessage---
Hi,

 

I can't remember if this is the PHP list for RPG programmers or not, so
apologize if this is the wrong one.

 

Is there an equivalent command in PHP for the SELECT statement in RPG? I see
switch, which is a little similar, but far from how it actually functions.

 

For those not familiar with the SELECT statement here is how I envision it
working in a PHP format similar to switch:

 

SELECT {

WHEN $Auth = 0:

WHEN $A = 1:

echo('$Aprint_list');

WHEN $B = 1:

echo('$Bprint_list');

WHEN $A = 2:

echo('$Aprint_list');

echo('$Aprint_list');

WHEN $B = 2:

echo('$Bprint_list');

echo('$Bprint_list');

DEFAULT:

}

 

The syntax may be a little off, but you get the picture. No breaks are
needed because it only performs the first match it comes to, then exits the
SELECT statement when finished the commands