php-general Digest 10 Oct 2007 14:37:22 -0000 Issue 5065

2007-10-10 Thread php-general-digest-help
php-general Digest 10 Oct 2007 14:37:22 - Issue 5065 Topics (messages 263022 through 263041): Re: Beginner Tutorials for using CLASSES in PHP4 263022 by: Nathan Nobbe 263026 by: tedd 263028 by: Tony Marston 263029 by: Tony Marston 263032 by: Nathan

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Per Jessen
Robert Cummings wrote: On Tue, 2007-10-09 at 15:28 -0500, Jay Blanchard wrote: [snip] This *IS* the knapsack problem. Just because you specify date ranges to get your values and the value isn't a knapsack doesn't change the fact that it is the same problem :) I remember having fun with

Re: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Robin Vickery
On 09/10/2007, Jay Blanchard [EMAIL PROTECTED] wrote: Good afternoon gurus and guru-ettes! I am searching for an algorithm that will take a list of monetary values and determine which of these values totals a value supplied to the widget. 1. I supply a value to the application and give a

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Jay Blanchard
[snip] it is a special case of the knapsack problem - the subset sum problem. You'll need to be aware that it's of exponential complexity. So make sure your lists of possible values don't get big. Anyway, here's my answer: [/snip] Thanks to all who responded, some very cool solutions and some

[PHP] Editing an element within an array

2007-10-10 Thread Brian Dunning
I have a two-dimensional array that looks like this: array( array(0, 123), array(0, 234), array(0, 345), array(0, 456) ) I want to REMOVE any element that contains 234, and I want to INCREMENT the first value for any element that contains 345, to make it look

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
Larry Garfield [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tuesday 09 October 2007, Tony Marston wrote: I have bought and read several books on design patterns without being impressed. I have seen countless examples of how particular design patterns can be implemented,

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] At 9:54 PM -0400 10/9/07, Nathan Nobbe wrote: i hope i have been able to contribute something to someone amidst all the arguing. -nathan Yeah, you gave me a better appreciation of some of the members of this list -- we have

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread tedd
At 9:54 PM -0400 10/9/07, Nathan Nobbe wrote: i hope i have been able to contribute something to someone amidst all the arguing. -nathan Yeah, you gave me a better appreciation of some of the members of this list -- we have some smart people here (i.e., Rob, Tony, Larry). Cheers, tedd

Re: [PHP] Re: Something you can do with AJAX + PHP as well

2007-10-10 Thread Per Jessen
Colin Guthrie wrote: What do you think of this? http://webbytedd.com/b/timed-php/ It's a combination of using both ajax and php together. I'd say overkill for the end result (could be done in plain Javascript without any Ajax calls), That was my reaction too. I've used iframe/rpc for

Re: [PHP] Editing an element within an array

2007-10-10 Thread Stut
Brian Dunning wrote: I have a two-dimensional array that looks like this: array( array(0, 123), array(0, 234), array(0, 345), array(0, 456) ) I want to REMOVE any element that contains 234, and I want to INCREMENT the first value for any element that contains 345, to make it

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, tedd [EMAIL PROTECTED] wrote: At 9:54 PM -0400 10/9/07, Nathan Nobbe wrote: i hope i have been able to contribute something to someone amidst all the arguing. -nathan Yeah, you gave me a better appreciation of some of the members of this list -- we have some smart people

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 07:00 -0500, Jay Blanchard wrote: There is another ongoing thread about OOP in PHP4 that has approached holy war status. I fear that some are overlooking solutions to problems that already have been solved. Things such as interfaces and design patterns exist because they

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 08:55 -0400, tedd wrote: At 9:54 PM -0400 10/9/07, Nathan Nobbe wrote: i hope i have been able to contribute something to someone amidst all the arguing. -nathan Yeah, you gave me a better appreciation of some of the members of this list -- we have some smart

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Tony Marston [EMAIL PROTECTED] wrote: There's your problem, then. You are wasting

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-10-09 at 21:37 -0400, Nathan Nobbe wrote: does a lawn mower not have blades; and gas and a control panel; does it not have wheels? my object

Re: [PHP] Editing an element within an array

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 14:36 +0100, Stut wrote: Brian Dunning wrote: A pint of cachaça to he who sets me on the path to success. Don't really know what that is, but OK! I'll be back with your pint a minute... right now I have to go to the washroom... why am I carrying this empty pint

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 14:44 +0100, Tony Marston wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-10-09 at 21:37 -0400, Nathan Nobbe wrote: does a lawn mower not have blades; and gas and a

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Tony Marston [EMAIL

Re: [PHP] Editing an element within an array

2007-10-10 Thread Stut
Robert Cummings wrote: On Wed, 2007-10-10 at 14:36 +0100, Stut wrote: Brian Dunning wrote: A pint of cachaça to he who sets me on the path to success. Don't really know what that is, but OK! I'll be back with your pint a minute... right now I have to go to the washroom... why am I carrying

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-10-09 at 21:37 -0400, Nathan Nobbe wrote: does a lawn mower not have blades; and gas and a

Re: [PHP] Extracting text from PDF files

2007-10-10 Thread David Giragosian
On 10/9/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] I need to extract the text from a PDF file for storage in the database. [/snip] It depends. If the PDF is an image file you cannot do it with PHP. http://www.php.net/pdf read the second user note [snip] Madison, WI 53703

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Instruct ICC
If the OP wants any single valid set, then this seems to work. If he wants all valid sets, no joy. I added a 10.00 and a 0.22 to the $values array and varied the position of the 10.00 (before and after 3.76) and it seems to pull the first set where the first member in the $values array is a

RE: [PHP] Looking for help with a complex algorithm

2007-10-10 Thread Jay Blanchard
[snip] If the OP wants any single valid set, then this seems to work. If he wants all valid sets, no joy. I added a 10.00 and a 0.22 to the $values array and varied the position of the 10.00 (before and after 3.76) and it seems to pull the first set where the first member in the $values array is a

Re: [PHP] How to format CLI tabular data?

2007-10-10 Thread tedd
At 12:30 PM -0700 10/9/07, Jim Lucas wrote: tedd wrote: Thanks for the code. I've altered it to display a table in a browser: http://webbytedd.com/bbb/table/ Code is shown there. -snip- I wouldn't use that to display tabular data in a browser. I will attach what I use to display in a

Re: [PHP] How to format CLI tabular data?

2007-10-10 Thread tedd
At 12:30 PM -0700 10/9/07, Jim Lucas wrote: tedd wrote: At 12:05 AM -0700 10/9/07, Jim Lucas wrote: Daevid Vincent wrote: Does PHP have any tools like this? I'd prefer not to pull in some PEAR package or other bloat, but I'll take what I can get if it actually works well. I was hoping there

[PHP] IIS 6 and php.ini not being friends

2007-10-10 Thread Philip Thompson
Hi. I have installed PHP ~ a dozen times on Windows and *nix systems, so I don't consider myself to be a newbie at this. However, I've run into a problem that I have run out of ideas. I have Google'd many sites and none of the suggestions provided worked for me. Specs: PHP 5.2.4 (Manual install)

Re: [PHP] IIS 6 and php.ini not being friends

2007-10-10 Thread Stut
Philip Thompson wrote: Hi. I have installed PHP ~ a dozen times on Windows and *nix systems, so I don't consider myself to be a newbie at this. However, I've run into a problem that I have run out of ideas. I have Google'd many sites and none of the suggestions provided worked for me. Specs:

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
and here is the interface example youve (Tony) been asking for. the reason an interface is the best option here is because human hands and grass are not related, but they can both be cut (i didnt start the fingers thing, but it works for the example so im using it). also, notice the benefit of

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
All your examples all falling on deaf ears. The fact of the matter is that encapsulation does NOT mean data hiding, therefore I do NOT have to make all my member variables private. The fact that you have used interfaces in that example proves nothing to me. It is possible to code a solution

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Tony Marston [EMAIL PROTECTED] wrote: All your examples all falling on deaf ears. The fact of the matter is that encapsulation does NOT mean data hiding, therefore I do NOT have to make all my member variables private. i thought we agreed to disagree on that point; im done

Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Don Proshetsky [EMAIL PROTECTED] wrote: Hi, I have a field in which a user inputs a Windows style directory path, hence using backslashes and not forward slashes. Example: c:\qb\data\mydatadile.qbw However, when the use clicks update, what gets saved is:

[PHP] round()

2007-10-10 Thread tedd
Hi gang: While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] round()

2007-10-10 Thread David Giragosian
On 10/10/07, tedd [EMAIL PROTECTED] wrote: Hi gang: While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Yes. sprintf

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Larry Garfield [EMAIL PROTECTED] wrote: On Wed, 10 Oct 2007 13:39:31 -0400, Nathan Nobbe [EMAIL PROTECTED] wrote: The fact that you have used interfaces in that example proves nothing to me. It is possible to code a solution which does not use interfaces, so what are

Re: [PHP] round()

2007-10-10 Thread Nathan Nobbe
On 10/10/07, tedd [EMAIL PROTECTED] wrote: Hi gang: While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? there is a function that uses the bc math library on the bc math pagehttp://www.php.net/manual/en/ref.bc.php ;

RE: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Jay Blanchard
[snip] so what are the benefits of the with interfaces solution over thewithout interfaces solution [/snip] Polymorphism. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Tony Marston [EMAIL PROTECTED] wrote: Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] so what are the benefits of the with interfaces solution over thewithout interfaces solution [/snip] Polymorphism. Are you saying that it is not possible

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] so what are the benefits of the with interfaces solution over thewithout interfaces solution [/snip] Polymorphism. Are you saying that it is not possible to have polymorphism without using interfaces? If so you

Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread TG
I didn't see all the responses to this, so maybe someone already recommended these things. Looks like you may be over-complicating things in your code there. First, if Magic Quotes are ON, then you probably want to stripslashes() to get rid of extra slashes. If it's OFF, then don't worry

RE: [PHP] round()

2007-10-10 Thread Instruct ICC
While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? For those that replied that there is a problem, can you provide examples? precision The optional number of decimal digits to round to, defaults to 0

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Tony Marston
Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/10/07, Tony Marston [EMAIL PROTECTED] wrote: Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] so what are the benefits of the with interfaces solution over thewithout interfaces

RE: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Jay Blanchard
[snip] I wouldn't play with a lawnmower class in the first place. I use PHP to write web applications which deal with database tables, not lawnmowers, and I have yet to find a good reason for using interfaces in such applications. Your contrived examples do not convince me of anything. [/snip]

RE: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 13:30 -0500, Jay Blanchard wrote: [snip] so what are the benefits of the with interfaces solution over thewithout interfaces solution [/snip] Polymorphism. Bleh, polymorphism isn't unique to interfaces. In fact, PHP has polymorphism all over the place by virtue of

RE: [PHP] round()

2007-10-10 Thread admin
While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? If you will refer to chafy's reply on 28-Feb-2007 06:13 http://us2.php.net/manual/en/function.round.php#73537 The function round numbers to a given precision.

RE: [PHP] IIS 6 and php.ini not being friends

2007-10-10 Thread Bastien Koert
why not try searching the c:/windows folder for a copy of the php.ini file? Maybe there is a straggler that needs to be deleted. Bastien Date: Wed, 10 Oct 2007 17:24:54 +0100 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: php-general@lists.php.net Subject: Re: [PHP] IIS 6 and php.ini

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-10-10 at 13:30 -0500, Jay Blanchard wrote: [snip] so what are the benefits of the with interfaces solution over thewithout interfaces solution [/snip] Polymorphism. Bleh, polymorphism isn't unique to interfaces.

RE: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread Bastien Koert
use mysql_real_escape_string bastien From: [EMAIL PROTECTED] To: php-general@lists.php.net Date: Wed, 10 Oct 2007 13:48:03 -0400 Subject: [PHP] How do I get PHP to save a backslash in a Mysql table? Hi, I have a field in which a user inputs a Windows style directory path, hence using

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread tedd
At 9:38 AM -0400 10/10/07, Nathan Nobbe wrote: On 10/10/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: At 9:54 PM -0400 10/9/07, Nathan Nobbe wrote: i hope i have been able to contribute something to someone amidst all the arguing. -nathan Yeah, you gave me a better

Re: [PHP] Re: Something you can do with AJAX + PHP as well

2007-10-10 Thread tedd
At 3:27 PM +0200 10/10/07, Per Jessen wrote: Colin Guthrie wrote: What do you think of this? http://webbytedd.com/b/timed-php/ It's a combination of using both ajax and php together. I'd say overkill for the end result (could be done in plain Javascript without any Ajax calls), That

Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread James Ausmus
On 10/10/07, Don Proshetsky [EMAIL PROTECTED] wrote: Hi, I have a field in which a user inputs a Windows style directory path, hence using backslashes and not forward slashes. Example: c:\qb\data\mydatadile.qbw However, when the use clicks update, what gets saved is:

Re: [PHP] IIS 6 and php.ini not being friends

2007-10-10 Thread Philip Thompson
On 10/10/07, Bastien Koert [EMAIL PROTECTED] wrote: why not try searching the c:/windows folder for a copy of the php.inifile? Maybe there is a straggler that needs to be deleted. Bastien - That may be a possibility... except I just built the machine yesterday, so I know php.ini is not in

Re: [PHP] round()

2007-10-10 Thread Bob Chatman
Why arent you just using sprintf? $var = 5.555; printf(%.2f, $var); # output : 5.56 printf(%.1f, $var); # output : 5.6 printf(%.0f, $var); # output : 6 On 10/10/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: While we're entertaining algorithms, has anyone else noticed that php's round()

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: What I was really illustrating is how interfaces are syntactic sugar only. In my above example what I've really shown is an implicit interface :) Since OOP is largely meant to model real world things, ask yourself this... when a doctor

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 17:46 -0400, Nathan Nobbe wrote: On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-10-10 at 13:30 -0500, Jay Blanchard wrote: [snip] so what are the benefits of the with interfaces solution over thewithout

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 17:46 -0400, Nathan Nobbe wrote: On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-10-10 at 13:30 -0500, Jay Blanchard wrote: [snip] so what are the benefits of the with interfaces solution over thewithout

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 20:45 -0400, Nathan Nobbe wrote: On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: What I was really illustrating is how interfaces are syntactic sugar only. In my above example what I've really shown is an implicit interface :) Since OOP is largely meant to

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 20:57 -0500, Larry Garfield wrote: On Wednesday 10 October 2007, Nathan Nobbe wrote: On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: What I was really illustrating is how interfaces are syntactic sugar only. In my above example what I've really shown is an

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Larry Garfield
On Wednesday 10 October 2007, Nathan Nobbe wrote: On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: What I was really illustrating is how interfaces are syntactic sugar only. In my above example what I've really shown is an implicit interface :) Since OOP is largely meant to model real

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
well i have to say i dont really see the difference between an implicit and explicit interface. the example you gave looks like it works just like the example i gave. in your example the check for the function is performed at runtime. in the example i gave the check for the interface is

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Robert Cummings
On Wed, 2007-10-10 at 22:15 -0400, Nathan Nobbe wrote: well i have to say i dont really see the difference between an implicit and explicit interface. the example you gave looks like it works just like the example i gave. in your example the check for the function is performed at runtime.

Re: [PHP] Beginner Tutorials for using CLASSES in PHP4

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-10-10 at 22:15 -0400, Nathan Nobbe wrote: well i have to say i dont really see the difference between an implicit and explicit interface. the example you gave looks like it works just like the example i gave. in your