php-general Digest 9 May 2008 09:40:50 -0000 Issue 5449

2008-05-09 Thread php-general-digest-help

php-general Digest 9 May 2008 09:40:50 - Issue 5449

Topics (messages 274039 through 274055):

Recursion... Sort of...
274039 by: Matt Neimeyer
274040 by: Nathan Nobbe
274044 by: Jim Lucas
274045 by: David Otton
274047 by: Nathan Nobbe
274050 by: Stut

Re: Setting up a program that can be accessed by all domain on a server
274041 by: Nathan Nobbe

Re: mysql query and maximum characters in sql statement
274042 by: Chris

Re: Where to start!
274043 by: Mark Weaver

Re: AI file and mapping with PHP
274046 by: paragasu

Odd performance problem
274048 by: Joeri Sebrechts
274049 by: Robert Cummings

PHP/SOAP WDSL Restrictions
274051 by: Paul van Brouwershaven
274052 by: Paul van Brouwershaven

Re: Newbie - is there a function similar to the sql 'like' comparison operator?
274053 by: Colin Guthrie

quick question
274054 by: Merca, Ansta Ltd

Get array as string --Help
274055 by: Shelley

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Is there a way to tell if a function has been called that has resulted
in a call to the same function?

We have an in-house CRM app that has a function that draws a tabbed
panel on a screen... BUT if there are sub-sub-tabbed panels we want to
invert the tab colors and panel colors...

So...

DrawSubTab($Set) - Black on White
   Content
   DrawSubTab($Set) - White on Black
  Content
  DrawSubTab($Set) - Black on White
 Content
  DrawSubTab($Set) - Black on White
 Content
 Etc...

I suppose I could rewrite EVERY call to the function with a recursion
count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
commit... whereas if the function can determine itself... All that
said I can't think of a good way to do it without a bastardized global
variable that track how deep we are and there is something that
bothers me about that approach... Unless that really is the easiest
way.

Thanks in advance!

Matt
---End Message---
---BeginMessage---
On Thu, May 8, 2008 at 3:48 PM, Matt Neimeyer [EMAIL PROTECTED] wrote:

 Is there a way to tell if a function has been called that has resulted
 in a call to the same function?

 We have an in-house CRM app that has a function that draws a tabbed
 panel on a screen... BUT if there are sub-sub-tabbed panels we want to
 invert the tab colors and panel colors...

 So...

 DrawSubTab($Set) - Black on White
   Content
   DrawSubTab($Set) - White on Black
  Content
  DrawSubTab($Set) - Black on White
 Content
  DrawSubTab($Set) - Black on White
 Content
 Etc...

 I suppose I could rewrite EVERY call to the function with a recursion
 count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
 commit... whereas if the function can determine itself... All that
 said I can't think of a good way to do it without a bastardized global
 variable that track how deep we are and there is something that
 bothers me about that approach... Unless that really is the easiest
 way.


you dont need a global, you can have a variable that persists throughout the
request local only to the function itself using the static keyword.

function doStuff() {
  static $callCount;

  if(!isset($callCount))
   $callCount = 1;
  else
$callCount++;

  /// do stuff w/ $callCount to potentially handle sub-tabs and stuff

  $callCount--;
}

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

Nathan Nobbe wrote:

On Thu, May 8, 2008 at 3:48 PM, Matt Neimeyer [EMAIL PROTECTED] wrote:


Is there a way to tell if a function has been called that has resulted
in a call to the same function?

We have an in-house CRM app that has a function that draws a tabbed
panel on a screen... BUT if there are sub-sub-tabbed panels we want to
invert the tab colors and panel colors...

So...

DrawSubTab($Set) - Black on White
  Content
  DrawSubTab($Set) - White on Black
 Content
 DrawSubTab($Set) - Black on White
Content
 DrawSubTab($Set) - Black on White
Content
Etc...

I suppose I could rewrite EVERY call to the function with a recursion
count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
commit... whereas if the function can determine itself... All that
said I can't think of a good way to do it without a bastardized global
variable that track how deep we are and there is something that
bothers me about that approach... Unless that really is the easiest
way.



you dont need a global, you can have a variable that persists throughout the
request local only to the function itself using the static keyword.

function doStuff() {
  static $callCount;

  if(!isset($callCount))
   $callCount = 

[PHP] Odd performance problem

2008-05-09 Thread Joeri Sebrechts
Hello,

While debugging a script that ran too slowly I came across something that I 
can't explain.

It is inactive code that when removed doubles the run time of the script.

Specifically, the issue is a switch statement, where one of the cases is 
never reached. If I remove the case from the code, the run time of the 
script goes from 6 seconds to 12 seconds.

To see this problem in action, you can download the problematic script here:
http://sebrechts.net/files/2008/phpperfissue.zip

Anyone have any ideas on how this is even possible? I'd like to improve the 
run time of the script, but if every part of code that I take out makes it 
run longer ...

Thanks 



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



Re: [PHP] Odd performance problem

2008-05-09 Thread Robert Cummings

On Wed, 2008-05-07 at 17:31 +0200, Joeri Sebrechts wrote:
 Hello,
 
 While debugging a script that ran too slowly I came across something that I 
 can't explain.
 
 It is inactive code that when removed doubles the run time of the script.
 
 Specifically, the issue is a switch statement, where one of the cases is 
 never reached. If I remove the case from the code, the run time of the 
 script goes from 6 seconds to 12 seconds.
 
 To see this problem in action, you can download the problematic script here:
 http://sebrechts.net/files/2008/phpperfissue.zip
 
 Anyone have any ideas on how this is even possible? I'd like to improve the 
 run time of the script, but if every part of code that I take out makes it 
 run longer ...

Runs the same for me either way... under PHP4 and PHP5. You must have a
nice system, takes 22 seconds both ways on my Athlon 2400 :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Stut

On 9 May 2008, at 02:02, Nathan Nobbe wrote:

function doStuff() {
static $callCount;

if(!isset($callCount))
 $callCount = 1;
else
  $callCount++;

/// do stuff w/ $callCount to potentially handle sub-tabs and stuff
   if($callCount == 2) {
 echo 'white on black';
   } else {
 echo 'black on white';
   }
   echo PHP_EOL;
}


No need for the first if, just give the static var a default value...

function doStuff() {
static $callCount = 0;
$callCount++;
...
}

Much neater.

-Stut

--
http://stut.net/

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



[PHP] PHP/SOAP WDSL Restrictions

2008-05-09 Thread Paul van Brouwershaven

Hi All,

I'm struggling with the WDSL restrictions in PHP/SOAP for a while know. I would like to create some 
simple restrictions in my WDSL file.


The script are running both on the same server with PHP Version 5.2.6 with the 
official soap extension.

On both my client and server there is some error configuration:

error_reporting(E_ALL);

ini_set(soap.wsdl_cache_enabled, 0);
use_soap_error_handler(true);

In my WDSL file there are some restrictions like:

A rule to accept only numbers, PHP/SOAP is translating not numbers to 0. (but I 
want an error message!)

xsd:element name=streetNumber minOccurs=1 maxOccurs=1 type=xsd:int

Almost the same for this more advanced restriction, you can provide every string. There is no error 
message and the whole string is accepted by my server.


xsd:simpleType name=Email
xsd:restriction base=xsd:string
xsd:pattern
value=^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL 
PROTECTED](\.[a-z0-9-]+)*$
/xsd:pattern
/xsd:restriction
/xsd:simpleType

I hope there are some people that have some more experience with PHP/SOAP and the use of 
restrictions who can help me with this!


Best regards,

Paul

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



[PHP] Re: PHP/SOAP WDSL Restrictions

2008-05-09 Thread Paul van Brouwershaven

 I'm struggling with the WDSL restrictions in PHP/SOAP for a while
Sorry, I mean WSDL instead of WDSL.

But of course the problem stays the same :-)

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



[PHP] Re: Newbie - is there a function similar to the sql 'like' comparison operator?

2008-05-09 Thread Colin Guthrie

revDAVE wrote:

Newbie - is there a function similar to the sql 'like' comparison operator?

I would like to be able to compare 2 strings:

If $this ---*like or similar to*--- $that

That type of thing...


I strongly suggest you read up on regular expressions:
http://uk.php.net/manual/en/book.regex.php

Knowing how to use regular expressions is a a very handy skill. I do a 
lot of mass changing of files via the command line with tools such as 
grep, sed and awk and a mastery regular expressions can save hours of 
laborious typing and find/replacing ;)


Reminds me of one of my favourite xkcd cartoons:
http://xkcd.com/208/

Col


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



[PHP] quick question

2008-05-09 Thread Merca, Ansta Ltd

Hi

Ho to read date from HTML form -
How to read $_POST['date']=dd/mm/ string variable as a date?

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



[PHP] Get array as string --Help

2008-05-09 Thread Shelley
Hi all,

If I have an array like this:
$arr = array (
'c' = 'd',
'e' = 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

-- 
Regards,
Shelley


Re: [PHP] Get array as string --Help

2008-05-09 Thread James Dempster
serialize

--
/James

On Fri, May 9, 2008 at 10:40 AM, Shelley [EMAIL PROTECTED] wrote:

 Hi all,

 If I have an array like this:
 $arr = array (
'c' = 'd',
'e' = 'f');

 How can I convert this array into a string? I want to write an array into a
 file.

 Thanks in advance.

 --
 Regards,
 Shelley



[PHP] british date format

2008-05-09 Thread Merca, Ansta Ltd

Hi

Anyone dd/mm/ as a date variable? strtotime - works fine with 
mm/dd/ but now with dd/mm/. (PHP 4.x)


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



RE: [PHP] Get array as string --Help

2008-05-09 Thread Chetan Rane
What is the format you want it to be

You can use JSON_encode(array());

To get into a text like representation 

Chetan Dattaram Rane
Software Engineer
 
 

-Original Message-
From: Shelley [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [PHP] Get array as string --Help

Hi all,

If I have an array like this:
$arr = array (
'c' = 'd',
'e' = 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

-- 
Regards,
Shelley


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



RE: [PHP] Get array as string --Help

2008-05-09 Thread Chetan Rane
Yet another option is use serialize(array())

Chetan Dattaram Rane
Software Engineer
 
 

-Original Message-
From: Shelley [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [PHP] Get array as string --Help

Hi all,

If I have an array like this:
$arr = array (
'c' = 'd',
'e' = 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

-- 
Regards,
Shelley


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



RE: [PHP] Get array as string --Help

2008-05-09 Thread Zoltán Németh
 Yet another option is use serialize(array())

or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh


 Chetan Dattaram Rane
 Software Engineer



 -Original Message-
 From: Shelley [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 09, 2008 3:11 PM
 To: PHP General list
 Subject: [PHP] Get array as string --Help

 Hi all,

 If I have an array like this:
 $arr = array (
 'c' = 'd',
 'e' = 'f');

 How can I convert this array into a string? I want to write an array into
 a
 file.

 Thanks in advance.

 --
 Regards,
 Shelley


 --
 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



RES: [PHP] Odd performance problem

2008-05-09 Thread Thiago Pojda
My tests on PHP 4.4.8

Default files:

Run 1)
done at 100045

Time: 12.5804 Seconds

Run 2)
done at 100045

Time: 12.6775 Seconds

Run 3)
done at 100045

Time: 13.0696 Seconds

Now editing the file, removed the switch case 'a' part.

Run 1) 
done at 100045

Time: 12.6981 Seconds

Run 2)
done at 100045

Time: 12.8659 Seconds

Run 3)
done at 100045

Time: 12.7886 Seconds

As you can see, there's no really big difference here. It really does look
like it's slower, but .1 sec slower.


Hey Robert, this was just a semprom 3k... didn't know they were that dif



Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros

-Mensagem original-
De: Robert Cummings [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 9 de maio de 2008 04:44
Para: Joeri Sebrechts
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Odd performance problem

On Wed, 2008-05-07 at 17:31 +0200, Joeri Sebrechts wrote:
 Hello,
 
 While debugging a script that ran too slowly I came across something that
I 
 can't explain.
 
 It is inactive code that when removed doubles the run time of the script.
 
 Specifically, the issue is a switch statement, where one of the cases is 
 never reached. If I remove the case from the code, the run time of the 
 script goes from 6 seconds to 12 seconds.
 
 To see this problem in action, you can download the problematic script
here:
 http://sebrechts.net/files/2008/phpperfissue.zip
 
 Anyone have any ideas on how this is even possible? I'd like to improve
the 
 run time of the script, but if every part of code that I take out makes it

 run longer ...

Runs the same for me either way... under PHP4 and PHP5. You must have a
nice system, takes 22 seconds both ways on my Athlon 2400 :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
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] quick question

2008-05-09 Thread Richard Heyes

Ho to read date from HTML form -
How to read $_POST['date']=dd/mm/ string variable as a date?


If you want a unix timestamp then try investigating strtotime().

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



RES: [PHP] quick question

2008-05-09 Thread Thiago Pojda
What do you mean read a string as a date, a date object?

Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-Mensagem original-
De: Merca, Ansta Ltd [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 9 de maio de 2008 06:36
Para: php-general@lists.php.net
Assunto: [PHP] quick question

Hi

Ho to read date from HTML form -
How to read $_POST['date']=dd/mm/ string variable as a date?

-- 
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



RES: [PHP] Get array as string --Help

2008-05-09 Thread Thiago Pojda
Depending on your needs you could also use implode() and then save it to a
file.


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-Mensagem original-
De: Zoltán Németh [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [PHP] Get array as string --Help

 Yet another option is use serialize(array())

or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh


 Chetan Dattaram Rane
 Software Engineer



 -Original Message-
 From: Shelley [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 09, 2008 3:11 PM
 To: PHP General list
 Subject: [PHP] Get array as string --Help

 Hi all,

 If I have an array like this:
 $arr = array (
 'c' = 'd',
 'e' = 'f');

 How can I convert this array into a string? I want to write an array into
 a
 file.

 Thanks in advance.

 --
 Regards,
 Shelley


 --
 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





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



RE: [PHP] Get array as string --Help

2008-05-09 Thread Chetan Rane
Yea but implde will loose the Keys

Chetan Dattaram Rane
Software Engineer
 
 
-Original Message-
From: Thiago Pojda [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 5:30 PM
To: 'Zoltán Németh'; 'Chetan Rane'
Cc: 'Shelley'; 'PHP General list'
Subject: RES: [PHP] Get array as string --Help

Depending on your needs you could also use implode() and then save it to a
file.


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-Mensagem original-
De: Zoltán Németh [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [PHP] Get array as string --Help

 Yet another option is use serialize(array())

or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh


 Chetan Dattaram Rane
 Software Engineer



 -Original Message-
 From: Shelley [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 09, 2008 3:11 PM
 To: PHP General list
 Subject: [PHP] Get array as string --Help

 Hi all,

 If I have an array like this:
 $arr = array (
 'c' = 'd',
 'e' = 'f');

 How can I convert this array into a string? I want to write an array into
 a
 file.

 Thanks in advance.

 --
 Regards,
 Shelley


 --
 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





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



Re: [PHP] quick question

2008-05-09 Thread Richard Heyes
Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems 
mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it didn't 


strtotime() returns a unix timestamp (ie number of seconds since 
1970ish. Nothing to do with the date object.


--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] quick question

2008-05-09 Thread Stut


Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems  
mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it  
didn't


If you're sure that's the format of the date, this will do it...

list($day, $month, $year) = explode('/', $thedate);
$thetimestamp = mktime(0, 0, 0, $month, $day, $year);

-Stut

--
http://stut.net/

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



Re: [PHP] Re: Where to start!

2008-05-09 Thread David Giragosian
I doubt this will have any sway on the contributors to this thread,
but I ran across a db normalization rule of thumb yesterday in a
tutorial for another language: Normalize until it hurts; De-normalize
until it works.

I lean towards finding a middle ground, so this makes sense to me.

--David.

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



Re: [PHP] Odd performance problem

2008-05-09 Thread Joeri Sebrechts
Ha, I tried again today, and now there's no difference. I'm thinking now 
that this was some sort of page boundary issue, or something of the sort. On 
the one hand it's a relief I can move on, on the other hand it's frustrating 
because I know for a fact that I saw those differences, and this problem 
might be happening for some of our customers.

I'll just blame windows, that always works :)

By the way, a 22 second run-time is definitely abnormal. I only have a 3 ghz 
P4, a 3 year old machine. When I disable xdebug it takes 4.5 seconds. 
Another by the way, while measuring the performance of this script I noticed 
that wincachegrind's time reports are incorrect. It reported a cumulative 
run-time of about one second. Kcachegrind (the KDE4 for windows version) did 
report correct times, so I'll be using that from now on.


Thiago Pojda [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
My tests on PHP 4.4.8

Default files:

Run 1)
done at 100045

Time: 12.5804 Seconds

Run 2)
done at 100045

Time: 12.6775 Seconds

Run 3)
done at 100045

Time: 13.0696 Seconds

Now editing the file, removed the switch case 'a' part.

Run 1)
done at 100045

Time: 12.6981 Seconds

Run 2)
done at 100045

Time: 12.8659 Seconds

Run 3)
done at 100045

Time: 12.7886 Seconds

As you can see, there's no really big difference here. It really does look
like it's slower, but .1 sec slower.


Hey Robert, this was just a semprom 3k... didn't know they were that dif



Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros

-Mensagem original-
De: Robert Cummings [mailto:[EMAIL PROTECTED]
Enviada em: sexta-feira, 9 de maio de 2008 04:44
Para: Joeri Sebrechts
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Odd performance problem

On Wed, 2008-05-07 at 17:31 +0200, Joeri Sebrechts wrote:
 Hello,

 While debugging a script that ran too slowly I came across something that
I
 can't explain.

 It is inactive code that when removed doubles the run time of the script.

 Specifically, the issue is a switch statement, where one of the cases is
 never reached. If I remove the case from the code, the run time of the
 script goes from 6 seconds to 12 seconds.

 To see this problem in action, you can download the problematic script
here:
 http://sebrechts.net/files/2008/phpperfissue.zip

 Anyone have any ideas on how this is even possible? I'd like to improve
the
 run time of the script, but if every part of code that I take out makes it

 run longer ...

Runs the same for me either way... under PHP4 and PHP5. You must have a
nice system, takes 22 seconds both ways on my Athlon 2400 :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
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] british date format

2008-05-09 Thread André Medeiros
Try this:

http://pt.php.net/manual/en/function.strptime.php

Use the result with mktime to get the timestamp. I also checked
set_locale but that won't interfere with strtotime :(

On Fri, May 9, 2008 at 9:58 AM, Merca, Ansta Ltd [EMAIL PROTECTED] wrote:
 Hi

 Anyone dd/mm/ as a date variable? strtotime - works fine with
 mm/dd/ but now with dd/mm/. (PHP 4.x)

 --
 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



[PHP] Re: british date format

2008-05-09 Thread Shawn McKenzie

Merca, Ansta Ltd wrote:

Hi

Anyone dd/mm/ as a date variable? strtotime - works fine with 
mm/dd/ but now with dd/mm/. (PHP 4.x)


setlocale()

and then...

http://pt.php.net/manual/en/function.strftime.php

-Shawn

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



Re: [PHP] Re: british date format

2008-05-09 Thread André Medeiros
Shawn,

I think the idea here was to get a timestamp from a date in that
format he was telling about.

After replying however, I noticed that strptime is only implemented in
PHP5. Sorry about that mate.

On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
 Merca, Ansta Ltd wrote:

 Hi

 Anyone dd/mm/ as a date variable? strtotime - works fine with
 mm/dd/ but now with dd/mm/. (PHP 4.x)

 setlocale()

 and then...

 http://pt.php.net/manual/en/function.strftime.php

 -Shawn

 --
 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: RES: [PHP] Odd performance problem

2008-05-09 Thread Robert Cummings

On Fri, 2008-05-09 at 08:42 -0300, Thiago Pojda wrote:

 Runs the same for me either way... under PHP4 and PHP5. You must have
 a nice system, takes 22 seconds both ways on my Athlon 2400 :)

Maybe it's because I use Evolution for my mail client and it has
steadily increased it's CPU suckage over the years. I have no idea what
it does but these days I noticed it's eating a steady 8-12% of my
CPU :( Unfortunately I didn't like Thunderbird last time I checked.
Maybe I'll give Opera's mail client a go since I use the Opera browser
anyways.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Nathan Nobbe
On Fri, May 9, 2008 at 1:52 AM, Stut [EMAIL PROTECTED] wrote:

 On 9 May 2008, at 02:02, Nathan Nobbe wrote:

 function doStuff() {
 static $callCount;

 if(!isset($callCount))
  $callCount = 1;
 else
  $callCount++;

 /// do stuff w/ $callCount to potentially handle sub-tabs and stuff
   if($callCount == 2) {
 echo 'white on black';
   } else {
 echo 'black on white';
   }
   echo PHP_EOL;
 }


 No need for the first if, just give the static var a default value...

 function doStuff() {
 static $callCount = 0;
 $callCount++;
 ...
 }

 Much neater.


in my haste i had also thought that would set the value to 0 every time the
function was called, heh.

-nathan


Re: [PHP] Re: british date format

2008-05-09 Thread Shawn McKenzie

André Medeiros wrote:

Shawn,

I think the idea here was to get a timestamp from a date in that
format he was telling about.

After replying however, I noticed that strptime is only implemented in
PHP5. Sorry about that mate.

On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:

Merca, Ansta Ltd wrote:

Hi

Anyone dd/mm/ as a date variable? strtotime - works fine with
mm/dd/ but now with dd/mm/. (PHP 4.x)

setlocale()

and then...

http://pt.php.net/manual/en/function.strftime.php

-Shawn

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



Couldn't see any other way.  *nix strtotime is supposed to use locale.

$date = '20/12/1971';
$parts = explode('/', $date);
echo mktime(0 ,0, 0, $d[1], $d[0],$d[2]).\n;

-Shawn

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



Re: [PHP] Re: british date format

2008-05-09 Thread Shawn McKenzie

Shawn McKenzie wrote:

André Medeiros wrote:

Shawn,

I think the idea here was to get a timestamp from a date in that
format he was telling about.

After replying however, I noticed that strptime is only implemented in
PHP5. Sorry about that mate.

On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie [EMAIL PROTECTED] 
wrote:

Merca, Ansta Ltd wrote:

Hi

Anyone dd/mm/ as a date variable? strtotime - works fine with
mm/dd/ but now with dd/mm/. (PHP 4.x)

setlocale()

and then...

http://pt.php.net/manual/en/function.strftime.php

-Shawn

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



Couldn't see any other way.  *nix strtotime is supposed to use locale.


Fixed that for me:

$date = '20/12/1971';
$d = explode('/', $date);
echo mktime(0 ,0, 0, $d[1], $d[0],$d[2]).\n;



-Shawn


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



Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Matt Neimeyer
Wow! Thanks guys! Here's what I ended up doing... To get...

Black on White - 1
  White on Black - 2
 Black on White - 3
 Black on White - 3
  White on Black - 2
 Black on White - 3

I had to do something like...


function doStuff()
  {
  static $callCount = 0;
  $callCount++;

  if($callCount%2)
 { echo 'white on black - '.$callCount; }
  else
 { echo 'black on white - '.$callCount; }

  // Stuff that uses the depth count

  $callCount--;
  }

If I didn't put in the $callCount--; I ended up with something like this...

Black on White - 1
  White on Black - 2
 Black on White - 3
 White on Black - 4
  Black on White - 5
 White on Black - 6

I saw where it was said that oh he said it wasn't recursive... Sorry
I wasn't clearer. In my mind a true recursive function is a function
that operates on it's own output like a factorial... Not just a
function that is called inside itself.

This got me where I needed to be and it is GREATLY appreciated!

Matt

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



Re: [PHP] Re: british date format

2008-05-09 Thread André Medeiros
Yeah, that would be the way to do it ;)

On Fri, May 9, 2008 at 3:54 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
 Shawn McKenzie wrote:

 André Medeiros wrote:

 Shawn,

 I think the idea here was to get a timestamp from a date in that
 format he was telling about.

 After replying however, I noticed that strptime is only implemented in
 PHP5. Sorry about that mate.

 On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie [EMAIL PROTECTED]
 wrote:

 Merca, Ansta Ltd wrote:

 Hi

 Anyone dd/mm/ as a date variable? strtotime - works fine with
 mm/dd/ but now with dd/mm/. (PHP 4.x)

 setlocale()

 and then...

 http://pt.php.net/manual/en/function.strftime.php

 -Shawn

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


 Couldn't see any other way.  *nix strtotime is supposed to use locale.

 Fixed that for me:

 $date = '20/12/1971';
 $d = explode('/', $date);
 echo mktime(0 ,0, 0, $d[1], $d[0],$d[2]).\n;


 -Shawn

 --
 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



[PHP] php.ini

2008-05-09 Thread Michael Satterwhite
I'm trying to turn off magic quotes for a site. I've copied the php.ini 
from /etc/php5/apache2 to the web site directory. In this file, I've changed 
magic_quotes_gpc to read
magic_quotes.gpc = Off

When I run phpinfo() from this directory, it still shows magic quotes as being 
on. I'm guessing there is another configuration parameter (either in the 
Apache configuration or for php) that allows this to be processed. Would 
someone be so kind as to help me here; I admit ignorance. 

---Michael

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



RES: [PHP] php.ini

2008-05-09 Thread Thiago Pojda
phpinfo() should also tell you what php.ini is loaded. 

Did you check that?


Atenciosamente,

www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-Mensagem original-
De: Michael Satterwhite [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 9 de maio de 2008 13:47
Para: php-general@lists.php.net
Assunto: [PHP] php.ini

I'm trying to turn off magic quotes for a site. I've copied the php.ini 
from /etc/php5/apache2 to the web site directory. In this file, I've changed

magic_quotes_gpc to read
magic_quotes.gpc = Off

When I run phpinfo() from this directory, it still shows magic quotes as
being 
on. I'm guessing there is another configuration parameter (either in the 
Apache configuration or for php) that allows this to be processed. Would 
someone be so kind as to help me here; I admit ignorance. 

---Michael

-- 
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] php.ini

2008-05-09 Thread André Medeiros
I'm not sure PHP5 would read php.ini from that directory.

You should take in account that your hosting company may _NOT_ allow
you to change certain parameters. That said, try visiting
http://us2.php.net/configuration.changes and see how that works for
you.

Good luck

On Fri, May 9, 2008 at 4:47 PM, Michael Satterwhite [EMAIL PROTECTED] wrote:
 I'm trying to turn off magic quotes for a site. I've copied the php.ini
 from /etc/php5/apache2 to the web site directory. In this file, I've changed
 magic_quotes_gpc to read
magic_quotes.gpc = Off

 When I run phpinfo() from this directory, it still shows magic quotes as being
 on. I'm guessing there is another configuration parameter (either in the
 Apache configuration or for php) that allows this to be processed. Would
 someone be so kind as to help me here; I admit ignorance.

 ---Michael

 --
 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] php.ini (typo in previous)

2008-05-09 Thread Michael Satterwhite
There was a typo in my previous message asking the question. I typed a . 
instead of _. It's corrected below:

On Friday 09 May 2008 11:47:29 Michael Satterwhite wrote:
 I'm trying to turn off magic quotes for a site. I've copied the php.ini
 from /etc/php5/apache2 to the web site directory. In this file, I've
 changed magic_quotes_gpc to read
   magic_quotes_gpc = Off

 When I run phpinfo() from this directory, it still shows magic quotes as
 being on. I'm guessing there is another configuration parameter (either in
 the Apache configuration or for php) that allows this to be processed.
 Would someone be so kind as to help me here; I admit ignorance.

 ---Michael



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



[PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Jason Pruim

Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I am  
attempting to do some very basic math with some arrays... Here's the  
pseudo code that I'm working with:


NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's of  
pounds by 16 to grab ounces.


Display TotalWeight # Exploded Ounces.

Which I have working just fine for a single set of boxes...

My problem is I want to be able to automatically add say 50 boxes in a  
form to process the weight of each route...


So what I need to do is probably use some kind of a counter to loop  
through my $RoutePieces array and multiply by the $PieceWeight?  
$PieceWeight is a static number.


Now let me show you some abbreviated code to try and explain what I'm  
using right now:

?PHP
$i= 0;
$num= 2;
$PieceWeight = $_POST['txtPieceWeight'];
$RoutePieces[] = $_POST['txtRoutePieces'];
$RouteNumber[] = $_POST['txtRoute'];

$totalWeight = $PieceWeight * $RoutePieces/16;
$weightExplode = explode('.', $totalWeight);
//$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
// Use stut's method... Seems cleaner
$explodeOunces = ($totalWeight - intval($totalWeight)) * 16;

while($i = $num){
echo HTML

p
	Route Number:input type=text name=txtRoute[$i] size=4 value  
={$RouteNumber[$i]} Number of pieces: input type=text  
name=txtRoutePieces[$i] size=4  
value={$RoutePieces[$i]}labelTotal weight of route:  
{$weightExplode[0]} # {$explodeOunces} Ounces/label

/p


HTML;

$i++;
echo $i;
}
?

the $_POST array has the proper values stored properly... I just can't  
seem to figure out how to work with the values... Any ideas? Or slaps  
on the back of the head to wake me up a little? :)


I need help :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





Re: [PHP] php.ini

2008-05-09 Thread Wolf

 Michael Satterwhite [EMAIL PROTECTED] wrote: 
 I'm trying to turn off magic quotes for a site. I've copied the php.ini 
 from /etc/php5/apache2 to the web site directory. In this file, I've changed 
 magic_quotes_gpc to read
   magic_quotes.gpc = Off
 
 When I run phpinfo() from this directory, it still shows magic quotes as 
 being 
 on. I'm guessing there is another configuration parameter (either in the 
 Apache configuration or for php) that allows this to be processed. Would 
 someone be so kind as to help me here; I admit ignorance. 
 
 ---Michael
'

When making changes to Apache configuration read files, you have to RESTART 
APACHE before those changes take effect.

However you can use php's ini_set () function to set a number of settings on 
the fly that can be changed per page change.

HTH,
Wolf

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



Re: [PHP] php.ini

2008-05-09 Thread Adam Richardson
And, at some hosts you have to change the settings in htaccess as opposed to
php.ini.

On Fri, May 9, 2008 at 12:53 PM, André Medeiros [EMAIL PROTECTED]
wrote:

 I'm not sure PHP5 would read php.ini from that directory.

 You should take in account that your hosting company may _NOT_ allow
 you to change certain parameters. That said, try visiting
 http://us2.php.net/configuration.changes and see how that works for
 you.

 Good luck

 On Fri, May 9, 2008 at 4:47 PM, Michael Satterwhite [EMAIL PROTECTED]
 wrote:
  I'm trying to turn off magic quotes for a site. I've copied the php.ini
  from /etc/php5/apache2 to the web site directory. In this file, I've
 changed
  magic_quotes_gpc to read
 magic_quotes.gpc = Off
 
  When I run phpinfo() from this directory, it still shows magic quotes as
 being
  on. I'm guessing there is another configuration parameter (either in the
  Apache configuration or for php) that allows this to be processed. Would
  someone be so kind as to help me here; I admit ignorance.
 
  ---Michael
 
  --
  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] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Dan Joseph
On Fri, May 9, 2008 at 12:56 PM, Jason Pruim [EMAIL PROTECTED] wrote:

 Hi Everyone,

 SO it's friday, I'm tired, and I can't seem to think straight... I am
 attempting to do some very basic math with some arrays... Here's the pseudo
 code that I'm working with:

 NumberOfPieces * PieceWeight = TotalWeight

 explode total weight to get tenth's of pounds, then divide tenth's of
 pounds by 16 to grab ounces.

 Display TotalWeight # Exploded Ounces.

 Which I have working just fine for a single set of boxes...

 My problem is I want to be able to automatically add say 50 boxes in a form
 to process the weight of each route...

 So what I need to do is probably use some kind of a counter to loop through
 my $RoutePieces array and multiply by the $PieceWeight? $PieceWeight is a
 static number.

 Now let me show you some abbreviated code to try and explain what I'm using
 right now:
 ?PHP
$i= 0;
$num= 2;
$PieceWeight = $_POST['txtPieceWeight'];
$RoutePieces[] = $_POST['txtRoutePieces'];
$RouteNumber[] = $_POST['txtRoute'];

$totalWeight = $PieceWeight * $RoutePieces/16;
$weightExplode = explode('.', $totalWeight);
//$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
// Use stut's method... Seems cleaner
$explodeOunces = ($totalWeight - intval($totalWeight)) * 16;

while($i = $num){
echo HTML

p
Route Number:input type=text name=txtRoute[$i] size=4 value
 ={$RouteNumber[$i]} Number of pieces: input type=text
 name=txtRoutePieces[$i] size=4 value={$RoutePieces[$i]}labelTotal
 weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces/label
/p


 HTML;

$i++;
echo $i;
}
 ?

 the $_POST array has the proper values stored properly... I just can't seem
 to figure out how to work with the values... Any ideas? Or slaps on the back
 of the head to wake me up a little? :)

 I need help :P



 --

 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424-9337
 www.raoset.com
 [EMAIL PROTECTED]




Rather than a counter, you could use foreach:

foreach ( $RoutePieces as $key = $value )
{
 $blah = $value * $PieceWeight;
}

Make sense?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month. Reseller plans and
Dedicated servers available.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Recursion... Sort of...

2008-05-09 Thread tedd

At 5:48 PM -0400 5/8/08, Matt Neimeyer wrote:

Is there a way to tell if a function has been called that has resulted
in a call to the same function?

We have an in-house CRM app that has a function that draws a tabbed
panel on a screen... BUT if there are sub-sub-tabbed panels we want to
invert the tab colors and panel colors...

So...

DrawSubTab($Set) - Black on White
   Content
   DrawSubTab($Set) - White on Black
  Content
  DrawSubTab($Set) - Black on White
 Content
  DrawSubTab($Set) - Black on White
 Content
 Etc...

I suppose I could rewrite EVERY call to the function with a recursion
count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
commit... whereas if the function can determine itself... All that
said I can't think of a good way to do it without a bastardized global
variable that track how deep we are and there is something that
bothers me about that approach... Unless that really is the easiest
way.

Thanks in advance!

Matt


If the CRM app uses a browser, then it sounds like a problem that 
could be solved via css -- parent/child relationships.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread tedd

At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I 
am attempting to do some very basic math with some arrays... Here's 
the pseudo code that I'm working with:


NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's 
of pounds by 16 to grab ounces.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and 
you'll get ounces.


---


Display TotalWeight # Exploded Ounces.

Which I have working just fine for a single set of boxes...

My problem is I want to be able to automatically add say 50 boxes in 
a form to process the weight of each route...


How much does each box weight and how many boxes? That's all you need.

---

So what I need to do is probably use some kind of a counter to loop 
through my $RoutePieces array and multiply by the $PieceWeight? 
$PieceWeight is a static number.


Is $PieceWeight is a static number?

The last time I checked, the cost per oz for shipping depends upon 
the weight. The more weight, the less the cost per ounce. Is that not 
true?


---

As for the code, that's pretty simple.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Jason Pruim


On May 9, 2008, at 1:05 PM, Dan Joseph wrote:

On Fri, May 9, 2008 at 12:56 PM, Jason Pruim [EMAIL PROTECTED]  
wrote:



Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I am
attempting to do some very basic math with some arrays... Here's  
the pseudo

code that I'm working with:

NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's of
pounds by 16 to grab ounces.

Display TotalWeight # Exploded Ounces.

Which I have working just fine for a single set of boxes...

My problem is I want to be able to automatically add say 50 boxes  
in a form

to process the weight of each route...

So what I need to do is probably use some kind of a counter to loop  
through
my $RoutePieces array and multiply by the $PieceWeight?  
$PieceWeight is a

static number.

Now let me show you some abbreviated code to try and explain what  
I'm using

right now:
?PHP
  $i= 0;
  $num= 2;
  $PieceWeight = $_POST['txtPieceWeight'];
  $RoutePieces[] = $_POST['txtRoutePieces'];
  $RouteNumber[] = $_POST['txtRoute'];

  $totalWeight = $PieceWeight * $RoutePieces/16;
  $weightExplode = explode('.', $totalWeight);
  //$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
  // Use stut's method... Seems cleaner
  $explodeOunces = ($totalWeight - intval($totalWeight)) * 16;

  while($i = $num){
  echo HTML

  p
  Route Number:input type=text name=txtRoute[$i] size=4  
value

={$RouteNumber[$i]} Number of pieces: input type=text
name=txtRoutePieces[$i] size=4  
value={$RoutePieces[$i]}labelTotal
weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces/ 
label

  /p


HTML;

  $i++;
  echo $i;
  }
?

the $_POST array has the proper values stored properly... I just  
can't seem
to figure out how to work with the values... Any ideas? Or slaps on  
the back

of the head to wake me up a little? :)

I need help :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





Rather than a counter, you could use foreach:

foreach ( $RoutePieces as $key = $value )
{
$blah = $value * $PieceWeight;
}

Make sense?


The idea make sense, and I think it will work. But I'm getting this  
error:


[Fri May  9 13:19:33 2008] [error] PHP Fatal error:  Unsupported  
operand types in /Volumes/RAIDer/webserver/Documents/dev/weightcalc/ 
index.php on line 22



foreach ($RoutePieces as $key = $value){
$testWeight = $value * $PieceWeight; ---Line 22
}

Some quick trying tells me that the problem is my * I don't remember  
having this problem before. Is there another character I should use to  
multiply with? :)


Thanks for looking!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Jason Pruim

Hey tedd


On May 9, 2008, at 1:21 PM, tedd wrote:


At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I  
am attempting to do some very basic math with some arrays... Here's  
the pseudo code that I'm working with:


NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's  
of pounds by 16 to grab ounces.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and  
you'll get ounces.


It's actually for a weight calculator that we use for some of our  
mailings. when you take .226 and multiply that by 464 you get 104.864  
ounces.


I need to be able to display that as: 6 # 13.824 Ounces.



---


Display TotalWeight # Exploded Ounces.

Which I have working just fine for a single set of boxes...

My problem is I want to be able to automatically add say 50 boxes  
in a form to process the weight of each route...


How much does each box weight and how many boxes? That's all you need.


the routes can have anywhere from 1 piece to 800+ pieces.  and we can  
have as few as 1 route to as many as 50 or 60+






---

So what I need to do is probably use some kind of a counter to loop  
through my $RoutePieces array and multiply by the $PieceWeight?  
$PieceWeight is a static number.


Is $PieceWeight is a static number?

The last time I checked, the cost per oz for shipping depends upon  
the weight. The more weight, the less the cost per ounce. Is that  
not true?


Normally yes, but not in this case :) I'm using it so I don't have to  
sit there and count out 464 postcards. I can just throw them on my  
scale and get the total weight.





---

As for the code, that's pretty simple.


Then it's a simple It's a friday thing for me... My wife keeps  
rubbing in that today is her last day of work until mid august... :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread tedd

At 1:29 PM -0400 5/9/08, Jason Pruim wrote:

Hey tedd

On May 9, 2008, at 1:21 PM, tedd wrote:


At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I 
am attempting to do some very basic math with some arrays... 
Here's the pseudo code that I'm working with:


NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's 
of pounds by 16 to grab ounces.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and 
you'll get ounces.


It's actually for a weight calculator that we use for some of our 
mailings. when you take .226 and multiply that by 464 you get 
104.864 ounces.


I need to be able to display that as: 6 # 13.824 Ounces.


Well, that explains it. Now, it's Friday for me.

You know, if you take the total weight and divide that by the number 
of gorillas per lamp-pole you'll go back in time. I'm totally lost.


Sorry I couldn't be more help.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: british date format

2008-05-09 Thread Shawn McKenzie

André Medeiros wrote:

Yeah, that would be the way to do it ;)

On Fri, May 9, 2008 at 3:54 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:

Shawn McKenzie wrote:

André Medeiros wrote:

Shawn,

I think the idea here was to get a timestamp from a date in that
format he was telling about.

After replying however, I noticed that strptime is only implemented in
PHP5. Sorry about that mate.

On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie [EMAIL PROTECTED]
wrote:

Merca, Ansta Ltd wrote:

Hi

Anyone dd/mm/ as a date variable? strtotime - works fine with
mm/dd/ but now with dd/mm/. (PHP 4.x)

setlocale()

and then...

http://pt.php.net/manual/en/function.strftime.php

-Shawn

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



Couldn't see any other way.  *nix strtotime is supposed to use locale.


Fixed that for me:

$date = '20/12/1971';
$d = explode('/', $date);
echo mktime(0 ,0, 0, $d[1], $d[0],$d[2]).\n;


-Shawn

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




I was bored.  Just an example, and I named it _eur because I assume that 
all European dates are this way, but some may have a / or a - or . 
separator.  intval() is to remove preceding 0 or it is treated as octal.


?php

function strtotime_eur($date)
{
preg_match('|([0-9]{1,2})[/.-]([0-9]{1,2})[/.-]([0-9]{2,4})|',
$date, $parts);

if(count($parts) != 4) {
return false;
}
$d = intval($parts[1]);
$m = intval($parts[2]);
$y = intval($parts[3]);

return mktime(0 ,0, 0, $m, $d, $y);
}

?

-Shawn

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



[PHP] Re: php.ini

2008-05-09 Thread Shawn McKenzie

Michael Satterwhite wrote:
I'm trying to turn off magic quotes for a site. I've copied the php.ini 
from /etc/php5/apache2 to the web site directory. In this file, I've changed 
magic_quotes_gpc to read

magic_quotes.gpc = Off

When I run phpinfo() from this directory, it still shows magic quotes as being 
on. I'm guessing there is another configuration parameter (either in the 
Apache configuration or for php) that allows this to be processed. Would 
someone be so kind as to help me here; I admit ignorance. 


---Michael


You have to set it in your main php.ini, the one shown in phpinfo() or 
set it in a .htaccess in the web dir if permitted.  You can't just copy 
a php.ini into a dir and expect php to use it.


-Shawn

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



Re: RES: [PHP] php.ini

2008-05-09 Thread Michael Satterwhite
On Friday 09 May 2008 11:56:32 Thiago Pojda wrote:
 phpinfo() should also tell you what php.ini is loaded.

 Did you check that?

I hadn't thought to, but I just did. As expected, it's reading it 
from /etc/php5/apache2.


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



Re: [PHP] php.ini

2008-05-09 Thread Michael Satterwhite
On Friday 09 May 2008 11:59:25 Wolf wrote:

 When making changes to Apache configuration read files, you have to RESTART
 APACHE before those changes take effect.

 However you can use php's ini_set () function to set a number of settings
 on the fly that can be changed per page change.

As this is (should be) being read from the user directory containing the 
application instead of the global configuration file, I'd expect it to behave 
more like the .htaccess file. The use of .htaccess to override apache 
configurations doesn't require an apache restart.

I do know that on bluehost, they actually encourage people to use their own 
php.ini file in their web directory ... and users certainly don't have the 
authority to restart apache.

That said - just for grins, I *DID* restart apache2. It made no difference.

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



[PHP] Re: unsubscribe

2008-05-09 Thread Wolf

 bobcray [EMAIL PROTECTED] wrote: 
 unsubscribe

http://www.php.net and unsubscribe yourself.

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



Re: [PHP] php.ini

2008-05-09 Thread Nathan Nobbe
On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite [EMAIL PROTECTED]
wrote:

 I do know that on bluehost, they actually encourage people to use their own
 php.ini file in their web directory ... and users certainly don't have the
 authority to restart apache.

 That said - just for grins, I *DID* restart apache2. It made no difference.


(from before) /etc/php5/apache2 is a centralized directory; i surprised you
even have access to it on a shared host.  do you have your own instance of
linux?  either way i sincerely doubt thats the web directory.  i would try
putting a .htaccess file in your web root.

php_flag magic_quotes_gpc = Off

when you look at the output of phpinfo() there will be 2 columns.  one has
the heading 'master value'  the other has the heading 'local value'  is the
local value different than the master value?  it should be if the .htaccess
file is working correctly (though you many not have permission to use them
[but it is typical to allow php configuration via .htaccess on shared
hosts]).

-nathan


Re: [PHP] Re: unsubscribe

2008-05-09 Thread Jason Pruim


On May 9, 2008, at 2:39 PM, Wolf wrote:



 bobcray [EMAIL PROTECTED] wrote:

unsubscribe


http://www.php.net and unsubscribe yourself.


Or look at the bottom of ANY message posted to the list and look for  
this line:




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



Just a thought :)
--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] php.ini

2008-05-09 Thread Janet Valade

Nathan Nobbe wrote:

On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite [EMAIL PROTECTED]
wrote:

  

I do know that on bluehost, they actually encourage people to use their own
php.ini file in their web directory ... and users certainly don't have the
authority to restart apache.

That said - just for grins, I *DID* restart apache2. It made no difference.

Some web hosts allow you have have your own local php.ini. You just 
create an empty php.ini file in your main web directory. After you do 
that, the loaded configuration file shown in the output from phpinfo() 
will show the path to the local php.ini file. Then, just put the 
specific directive in there, such as:


magic_quotes_gpc = Off

This works on some hosts.

Janet

--

janet.valade.com


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



[PHP] xml processing cdata

2008-05-09 Thread Chris W
I have an xml file with a cdata element like the one below.  How would I 
use the php xml functions to extract that cdata and save it as a pdf file?


attach id=2 display-name=207069.pdf file-name=207069.pdf 
obj-type=1 system=0

 ![CDATA[eJysumVQW1/0NtoWK95CcXe3EFxK8QDBCQ5 .. ]]
/attach



The code I have is this...

$in = fopen(test.xml, 'r');
$XMLStr = '';
while (!feof($in)) {
 $LineNumber++;
 $XMLStr .= fgets($in);
}
$XML = simplexml_load_string($XMLStr);
foreach($XML-props-attachments-attach as $Attachment){
 print_r($Attachment);
}
The output looks like this...

SimpleXMLElement Object
(
   [EMAIL PROTECTED] = Array
   (
   [id] = 2
   [display-name] = 207069.pdf
   [file-name] = 207069.pdf
   [obj-type] = 1
   [system] = 0
   )

)


--
Chris W
KE5GIX

Protect your digital freedom and privacy, eliminate DRM, 
learn more at http://www.defectivebydesign.org/what_is_drm;


Ham Radio Repeater Database.
http://hrrdb.com


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



Re: [PHP] Why doesn't working with array's ever stick in my thickhead?

2008-05-09 Thread Roberto Mansfield
Roberto Mansfield wrote:

 (I'm assuming .226 is the cost per ounce and 464 is the total number of
 ounces)

It sure is Friday. This assumption doesn't make any sense!

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



Re: [PHP] Why doesn't working with array's ever stick in my thickhead?

2008-05-09 Thread Jason Pruim


On May 9, 2008, at 4:23 PM, Roberto Mansfield wrote:


Roberto Mansfield wrote:

(I'm assuming .226 is the cost per ounce and 464 is the total  
number of

ounces)


It sure is Friday. This assumption doesn't make any sense!


Yeah... and my work day is almost done! SO Happy Friday to you all!

Basically though, .226 is the weight of a single piece. we get it by  
weighing 100 pieces, and then dividing the total weight by 100.  that  
gives us the weight of a single piece in a tenth of a pound. And I  
need to display in pounds and ounces. I have that part figured out, I  
just need to fight with it so I can do it without having to type out  
in the code 50 fields to add the routes together :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



[PHP] usort inside a class

2008-05-09 Thread It Maq
Hi,

i'm trying to build a class that sorts a multidimensional array.
I'm using the php function usort.

I declared the comparision function as a method of my class but i'm unable to 
give it as argument to the function usort.

this usort($this-arr, $this-cmpi) gaves the following error: usort() 
[function.usort]: Invalid comparison function

i tried to do usort($this-arr, 'cmpi') but it does not work either.

Thanks


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Roberto Mansfield
Jason Pruim wrote:
 Why do you want tenth's of pounds? Just divide pounds by 16 and you'll
 get ounces.
 
 It's actually for a weight calculator that we use for some of our
 mailings. when you take .226 and multiply that by 464 you get 104.864
 ounces.
 
 I need to be able to display that as: 6 # 13.824 Ounces.

Then I think you want to use the mod operator:

(I'm assuming .226 is the cost per ounce and 464 is the total number of
ounces)

$pounds = intval( .226 * 464 / 16 );
$ounces = ( .226 * 464 ) % 16;


Roberto

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



Re: [PHP] usort inside a class

2008-05-09 Thread Richard Heyes

i'm trying to build a class that sorts a multidimensional array.
I'm using the php function usort.

I declared the comparision function as a method of my class but i'm unable to 
give it as argument to the function usort.

this usort($this-arr, $this-cmpi) gaves the following error: usort() 
[function.usort]: Invalid comparison function

i tried to do usort($this-arr, 'cmpi') but it does not work either.


If it's anything like other functions, try this:

usort($this-arr, array($this, 'cmpi'));

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] usort inside a class

2008-05-09 Thread It flance
It works thanks a lot!


--- On Fri, 5/9/08, Richard Heyes [EMAIL PROTECTED] wrote:

 From: Richard Heyes [EMAIL PROTECTED]
 Subject: Re: [PHP] usort inside a class
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Date: Friday, May 9, 2008, 8:47 PM
  i'm trying to build a class that sorts a
 multidimensional array.
  I'm using the php function usort.
  
  I declared the comparision function as a method of my
 class but i'm unable to give it as argument to the
 function usort.
  
  this usort($this-arr, $this-cmpi)
 gaves the following error: usort() [function.usort]:
 Invalid comparison function
  
  i tried to do usort($this-arr,
 'cmpi') but it does not work either.
 
 If it's anything like other functions, try this:
 
 usort($this-arr, array($this, 'cmpi'));
 
 -- 
 Richard Heyes
 
 ++
 | Access SSH with a Windows mapped drive |
 |http://www.phpguru.org/sftpdrive|
 ++


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



[PHP] Re: unsubscribe

2008-05-09 Thread tedd

At 2:39 PM -0400 5/9/08, Wolf wrote:

 bobcray [EMAIL PROTECTED] wrote:

 unsubscribe


http://www.php.net and unsubscribe yourself.


Yeah, I got that sent to me as well.

It's interesting when people are smart enough to subscribe, but 
dummy-up when exiting. Do you think this list saps intelligence?


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: [PHP-WIN] Include Question!

2008-05-09 Thread Stut
Please include the list when replying, unless you're willing to pay my  
standard hourly rate.


On 9 May 2008, at 20:49, Matthew Gonzales wrote:


Thanks for the responses. I think that I need to clarify.

I am looking to use an include to minimize the amount of code on the  
page. So  I wanted to use an include to call the code from another  
file. They are functions that query and update the databse and move  
uploaded files. Hope this make more sense.


That's fine, just be sure not to include the file more than once per  
request or you'll get error messages regarding redeclaration of  
functions. You can also use the _once variations of include or require  
to get around this but bear in mind this causes a small performance hit.


-Stut

--
http://stut.net/


Stut wrote:

On 9 May 2008, at 18:56, Bradley Stahl wrote:
Your code would essentially be inserted in the place where your  
include

statement is called.  Let's say that your in 'page.php' you had the
following code:

echo I AM IN PAGE.PHP!;

and then in your script you have your code:

if (some variable) {
  include('page.php');
}


This would essentially be giving you the code:

if(some variable) {
  echo I AM IN PAGE.PHP!;
}

I hope that this makes sense.. and this helps!


That's not quite right and I think it's important to understand  
exactly what PHP does here.


PHP is executing a file and encounters file inclusion (include/ 
require(_once)). PHP will load and compile the included file.  
During this stage it registers declarations in the global scope,  
i.e. classes and functions. After that it executes the included  
file in the same context from which it was included, so all local  
vars visible inside your if block will be accessible. Once that  
file's done PHP returns to executing the original file from the  
statement after the include.


Note that no code insertion takes place, it purely passes execution  
to the included file. It's this sequence that prevents you from  
defining a class across several files.


Hope that makes it clearer.

-Stut



--
Matthew Gonzales
IT Professional Specialist
Enterprise Information Technology Services
University of Georgia
Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Phone: (706)542-9538



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



Fwd: [PHP] php.ini

2008-05-09 Thread Nathan Nobbe
bouncing back to the list..

-- Forwarded message --
From: Michael Satterwhite [EMAIL PROTECTED]
Date: Fri, May 9, 2008 at 3:09 PM
Subject: Re: [PHP] php.ini
To: Nathan Nobbe [EMAIL PROTECTED]


On Friday 09 May 2008 13:43:27 you wrote:
 On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite [EMAIL PROTECTED]

 wrote:
  I do know that on bluehost, they actually encourage people to use their
  own php.ini file in their web directory ... and users certainly don't
  have the authority to restart apache.
 
  That said - just for grins, I *DID* restart apache2. It made no
  difference.

 (from before) /etc/php5/apache2 is a centralized directory; i surprised
you
 even have access to it on a shared host.  do you have your own instance of
 linux?  either way i sincerely doubt thats the web directory.  i would try
 putting a .htaccess file in your web root.

I never said it was the web directory ... I said that's where php.ini is
being
loaded from. The web directory is /var/www ... that's where the php.ini I
*WANT* loaded is. ...and, yes, I have my own Linux machine that I use for
testing.
 php_flag magic_quotes_gpc = Off

 when you look at the output of phpinfo() there will be 2 columns.  one has
 the heading 'master value'  the other has the heading 'local value'  is
the
 local value different than the master value?  it should be if the
.htaccess
 file is working correctly (though you many not have permission to use them
 [but it is typical to allow php configuration via .htaccess on shared
 hosts]).

I've tried that now, and it does work. I was trying to do it through a local
php.ini because I know that's the way bluehost makes us do it, and there are
several websites that document it as a working manner.

I do thank everyone for their help with this.


Re: [PHP] Re: unsubscribe

2008-05-09 Thread Nathan Nobbe
On Fri, May 9, 2008 at 2:57 PM, tedd [EMAIL PROTECTED] wrote:

 At 2:39 PM -0400 5/9/08, Wolf wrote:

  bobcray [EMAIL PROTECTED] wrote:

  unsubscribe


 http://www.php.net and unsubscribe yourself.


 Yeah, I got that sent to me as well.

 It's interesting when people are smart enough to subscribe, but dummy-up
 when exiting. Do you think this list saps intelligence?


im getting dumber by the day :O

-nathan


Re: [PHP] Re: unsubscribe

2008-05-09 Thread tedd

At 3:45 PM -0600 5/9/08, Nathan Nobbe wrote:
On Fri, May 9, 2008 at 2:57 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:



It's interesting when people are smart enough to subscribe, but 
dummy-up when exiting. Do you think this list saps intelligence?



im getting dumber by the day :O

-nathan


Yeah, we've noticed.

You've even had to resort to using classes and other strange stuff to 
program. Clearly signs of mental fatigue. :-)


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

Re: [PHP] Re: unsubscribe

2008-05-09 Thread Nathan Nobbe
On Fri, May 9, 2008 at 8:25 PM, tedd [EMAIL PROTECTED] wrote:

 At 3:45 PM -0600 5/9/08, Nathan Nobbe wrote:

 On Fri, May 9, 2008 at 2:57 PM, tedd mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:


 It's interesting when people are smart enough to subscribe, but dummy-up
 when exiting. Do you think this list saps intelligence?


 im getting dumber by the day :O

 -nathan


 Yeah, we've noticed.

 You've even had to resort to using classes and other strange stuff to
 program. Clearly signs of mental fatigue. :-)


and i thought oop was all about advances in technology; must be these
deadlines wearing on me...:D

-nathan


Re: [PHP] xml processing cdata

2008-05-09 Thread Brady Mitchell
The last comment on http://php.net/manual/en/function.simplexml-load-string.php 
 is what you need:


simplexml_load_string($xmlstring, 'SimpleXMLElement', LIBXML_NOCDATA);

Brady


On May 9, 2008, at 1250PM, Chris W wrote:

I have an xml file with a cdata element like the one below.  How  
would I use the php xml functions to extract that cdata and save it  
as a pdf file?


attach id=2 display-name=207069.pdf file-name=207069.pdf obj- 
type=1 system=0

![CDATA[eJysumVQW1/0NtoWK95CcXe3EFxK8QDBCQ5 .. ]]
/attach



The code I have is this...

$in = fopen(test.xml, 'r');
$XMLStr = '';
while (!feof($in)) {
$LineNumber++;
$XMLStr .= fgets($in);
}
$XML = simplexml_load_string($XMLStr);
foreach($XML-props-attachments-attach as $Attachment){
print_r($Attachment);
}
The output looks like this...

SimpleXMLElement Object
(
  [EMAIL PROTECTED] = Array
  (
  [id] = 2
  [display-name] = 207069.pdf
  [file-name] = 207069.pdf
  [obj-type] = 1
  [system] = 0
  )

)


--
Chris W
KE5GIX

Protect your digital freedom and privacy, eliminate DRM, learn more  
at http://www.defectivebydesign.org/what_is_drm;


Ham Radio Repeater Database.
http://hrrdb.com


--
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