php-general Digest 12 Jan 2010 05:08:45 -0000 Issue 6534

2010-01-11 Thread php-general-digest-help

php-general Digest 12 Jan 2010 05:08:45 - Issue 6534

Topics (messages 300992 through 301012):

Re: To add the final ?> or not...
300992 by: Bipper Goes!

Re: Formatting Decimals
300993 by: Rick Dwyer
300996 by: Paul M Foster
301002 by: tedd
301005 by: Rick Dwyer
301007 by: Mattias Thorslund
301008 by: Adam Richardson
301009 by: Paul M Foster

test
300994 by: LAMP
300995 by: LAMP
300997 by: Daniel Brown
300998 by: LAMP

Count the Number of Certain Elements in An Array
300999 by: Alice Wei
301000 by: Jonathan Tapicer
301001 by: Alice Wei

corect way to use mail() function
301003 by: LAMP
301004 by: Daevid Vincent
301010 by: Paul M Foster
301011 by: Daevid Vincent
301012 by: Angus Mann

Re: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1
301006 by: Don O'Neil

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
--- Begin Message ---
Ever write a string replace function on a closing ?> //somecomment here like
end junk

I have written some systems and gone back two to three years later and found
myself having to do such.  Sloppy, sure.  Minimize cost to the client?  Oh
yeah.

I keep em, and comment 'em as I feel I should.

On Mon, Jan 11, 2010 at 2:24 AM, Olav  wrote:

> Paul M Foster wrote:
>
> > I leave it off. I don't want to have to worry about which editor I'm
> > using or whether I accidentally left some whitespace where it shouldn't
> > be.
>
> I also use different editors in different situations, both terminal based
> and GUI. For instance I find Midnight Commander's internal editor quite
> comfortable to use but unfortunately it does leave whitespace all over
> the place.
>
> This discussion made me think. From now on, I will probably also leave
> the closing ?> off in include files. If something isn't really needed
> then there is no rational reason to insist on using it.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it  
gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware  
of the logic to configure this accordingly.


Thanks,
--Rick




On Jan 11, 2010, at 10:55 AM, Ryan Sun wrote:


$newprice =  sprintf("$%.2f", 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer   
wrote:

Hello List.

Probably an easy question, but I am not able to format a number to  
round up from 3 numbers after the decimal to just 2.


My code looks like this:

$newprice = "$".number_format($old_price, 2, ".", ",");

and this returns "$0.109" when I am looking for "$0.11".


I tried:

$newprice = "$".round(number_format($old_price, 2, ".", ","),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick



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





 --Rick


--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

> I have been asked to further modify the value to the nearest half cent.
>
> So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
> If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
> gets rounded up to full cents.
>
> Can this be done fairly easily?  Not knowing PHP well, I am not aware
> of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

http://us2.php.net/manual/en/book.bc.php

Paul

-- 
Paul M. Foster
--- End Message ---
--- Begin Message ---

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not 
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look

php-general Digest 11 Jan 2010 16:59:10 -0000 Issue 6533

2010-01-11 Thread php-general-digest-help

php-general Digest 11 Jan 2010 16:59:10 - Issue 6533

Topics (messages 300960 through 300991):

stream_socket_client via proxy
300960 by: kranthi

Re: Upgraded PHP now website doesn't work properly?
300961 by: Waynn Lue
300970 by: Ashley Sheridan
300971 by: Bob McConnell
300973 by: Kaya Saman
300974 by: Ashley Sheridan
300975 by: Robert Cummings
300976 by: Michael A. Peters
300979 by: Kaya Saman
300986 by: Michael A. Peters
300990 by: Kaya Saman

Form validation and save the form
300962 by: aditya shukla
300964 by: Paul M Foster
300977 by: Angelo Zanetti
300978 by: Robert Cummings
300980 by: aditya shukla
300983 by: Angelo Zanetti
300988 by: Bastien Koert

Re: To add the final ?> or not...
300963 by: Paul M Foster
300965 by: Olav

htmlMicroscope 1.2.0 out - much better than 1.1.0
300966 by: Rene Veerman

I am not receiving any e-mail from the list...
300967 by: Jay Blanchard
300968 by: metastable
300969 by: Jay Blanchard
300981 by: Richard
300982 by: Daniel Brown
300984 by: Ashley Sheridan
300985 by: Richard
300989 by: Bastien Koert

Easy Eclipse PHP Problem
300972 by: tedd

Re: Formatting Decimals
300987 by: Ryan Sun

Re: SVG and PHP
300991 by: haliphax

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
--- Begin Message ---
Hi all,

I am trying to use http://code.google.com/p/xmpphp/ package. It uses
stream_socket_client to connect to XMPP servers. I am behind a proxy
server so obviously this is not working. Tried proxychains but to no
avail.

Am I missing something obvious?

Kranthi.
--- End Message ---
--- Begin Message ---
Emacs/xemacs does syntax highlighting too.

On 1/10/10, Kaya Saman  wrote:
>
>>>
>>>
>> Depending on the latency and bandwidth you could use X11 forwarding
>> (granted the server supports it) so you could use a non-CLI editor. I
>> think "joe" has some syntax highlighting, but I've never edited PHP
>> files with it.
>> If you are coming from a windows machine, you can use Cygwin or Xming
>> to set up an X server on the box before SSHing to your data center
>> w/X11 forwarding enabled.
>>
>> -Ken Sande
> Many thanks to everyone!
>
> I currently use a mixture of FreeBSD, Linux, and Solaris/OpenSolaris as
> operating systems so X11 forwarding is not a problem but maybe quite
> slow considering the distance between me and my data center right now,
> and also I have only 1Mbps upstream as the data center uses ADSL which
> is a restriction on my behalf.
>
> Am using SFTP to transfer non-html related stuff and using simple nano
> or copy-paste from the Gnome terminal.
>
> Yeah many options available I know and I guess that's what makes things
> fun :-)
>
> Anyway I'm sure I'll work something out, at worst case I could always
> VPN once I get a Cisco router out here and get an IPsec tunnel going and
> do things over NFS mount??
>
> Regards,
>
> Kaya
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Mon, 2010-01-11 at 03:27 +0200, Kaya Saman wrote:

> >>
> >>
> > Depending on the latency and bandwidth you could use X11 forwarding 
> > (granted the server supports it) so you could use a non-CLI editor. I 
> > think "joe" has some syntax highlighting, but I've never edited PHP 
> > files with it.
> > If you are coming from a windows machine, you can use Cygwin or Xming 
> > to set up an X server on the box before SSHing to your data center 
> > w/X11 forwarding enabled.
> >
> > -Ken Sande
> Many thanks to everyone!
> 
> I currently use a mixture of FreeBSD, Linux, and Solaris/OpenSolaris as 
> operating systems so X11 forwarding is not a problem but maybe quite 
> slow considering the distance between me and my data center right now, 
> and also I have only 1Mbps upstream as the data center uses ADSL which 
> is a restriction on my behalf.
> 
> Am using SFTP to transfer non-html related stuff and using simple nano 
> or copy-paste from the Gnome terminal.
> 
> Yeah many options available I know and I guess that's what makes things 
> fun :-)
> 
> Anyway I'm sure I'll work something out, at worst case I could always 
> VPN once I get a Cisco router out here and get an IPsec tunnel going and 
> do things over NFS mount??
> 
> Regards,
> 
> Kaya


I never bother with X-forwarding for development work, it is too slow I
agree. I use Konqueror to connect as an FTP client, as it works really
well as a file manager with the split screen views it has. F