php-general Digest 17 Sep 2011 07:46:20 -0000 Issue 7482

Topics (messages 314900 through 314918):

Re: Help on number matching function
        314900 by: Robert Williams
        314901 by: Ken Robinson
        314908 by: Andre Polykanine
        314913 by: Mattias Thorslund
        314918 by: tamouse mailing lists

Re: Repetitive answers . . .
        314902 by: Daniel Brown

Re: XML enabled but not working
        314903 by: Richard Quadling
        314914 by: Matthew Pounsett
        314915 by: Richard Quadling
        314916 by: James Moe

Round with money_format
        314904 by: Cyril Lopez
        314905 by: Richard Quadling
        314906 by: Stuart Dallas
        314907 by: Stuart Dallas

Episode 2 - All The Cool Kids Use Ruby
        314909 by: Daevid Vincent
        314910 by: Jen Rasmussen
        314911 by: Robert Cummings
        314917 by: Bastien

Re: PHP 5.4.0beta1 released
        314912 by: Shawn McKenzie

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 ---
On Sep 16, 2011, at 6:02, "Dare Williams" <darrenwi...@yahoo.com> wrote:

>
>  I have a 5 Digits set of number  and need to match it with another set of 
> five  digits and return how many number are match and the figures that are 
> match.


Check out array_intersect().

<http://us.php.net/manual/en/function.array-intersect.php>

--
Bob Williams

Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--- End Message ---
--- Begin Message ---
At 08:36 AM 9/16/2011, Dare Williams wrote:
Dear PHP Group, I need a Function of any category in either PHP or MySQL RDBMS customize Function, Class, Methods or anything that could help me compare a particular set of number and return their matching result. e.g If I have a 5 Digits set of number and need to match it with another set of five digits and return how many number are match and the figures that are match. 1. (62,39,47,25,14) - (14,39,62,25,47) - match 5 (all) 2. (55,11,27,62,39) - (66,39,12,13,27) - match 2 (27,39) 3. (20,04,56,17,16) - (16,01,17,04,79) - match 3 (16,17,04) Any Help will be appreciated. Thank you.

Turn your sets of number into an array and then use the function array_intersect, http://php.net/array_intersect

Ken



--- End Message ---
--- Begin Message ---
Hello Dare,

      

DW> I need a Function of any category in  either PHP or MySQL RDBMS
DW> customize Function, Class, Methods or anything that could help me
DW> compare a particular set of number and return their matching
DW> result.

consider using array_intersect().


-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion


--- End Message ---
--- Begin Message --- If one or both of your data sets are in MySQL already, there may be no need to do the comparison in PHP. Just use IN() or INNER JOIN. Or is there some particular reason why neither of these will work in your case?

Cheers,

Mattias

On 09/16/2011 05:36 AM, Dare Williams wrote:
Dear PHP Group,

I need a Function of any category in  either PHP or MySQL RDBMS customize 
Function, Class, Methods or anything that could help me compare a particular 
set of number and return their matching result. e.g If I have a 5 Digits set of 
number  and need to match it with another set of five  digits and return how 
many number are match and the figures that are match.

1.    (62,39,47,25,14) - (14,39,62,25,47) - match 5 (all)
2.    (55,11,27,62,39) - (66,39,12,13,27) - match 2 (27,39)
3.    (20,04,56,17,16) - (16,01,17,04,79) - match 3 (16,17,04)

Any Help will be appreciated.

Thank you.




--- End Message ---
--- Begin Message ---
> Notice: This communication, including attachments, may contain
> information that is confidential. It constitutes non-public information
> intended to be conveyed only to the designated recipient(s). If the
> reader or recipient of this communication is not the intended
> recipient, an employee or agent of the intended recipient who is
> responsible for delivering it to the intended recipient, or if you
> believe that you have received this communication in error, please
> notify the sender immediately by return e-mail and promptly delete
> this e-mail, including attachments without reading or saving them
> in any manner. The unauthorized use, dissemination, distribution,
> or reproduction of this e-mail, including attachments, is prohibited
> and may be unlawful. If you have received this email in error,
> please notify us immediately by e-mail or telephone and delete the
> e-mail and the attachments (if any).

Not another one...

Sending e-mail to a public mailing list MUST be intended for the public.

--- End Message ---
--- Begin Message ---
On Thu, Sep 15, 2011 at 21:31, Joshua Stoutenburg <jehoshu...@gmail.com> wrote:
>
> But let me put a spin on it:
>
> <?php
>
> $information = <<<EOF
>
> I got a great idea, why don't we write hundreds of books and websites
> with all of our repetitive answers and call it the "information age".
> Who cares if all the priceless pearls of rare knowledge are buried,
> lost, and irretrievable.  We'll have the information age!
>
> Then, after we've ushered in the information age, we'll invent a
> search bot to crawl all over the heap of information and fling it
> around whenever somebody asks for it!
>
> Then, we'll all sit around on a mailing list, and when somebody comes
> in seeking refuge from the flinging search bot, looking for some rare
> piece of information, we'll fling all the common stuff at him instead!
>  It will be hilarious!
>
> EOF;
>
>
> class baboon
> {
>    $ammo = '';

    Parse error.  You probably mean: var $ammo;

>    public __construct($ammo)

    Parse error.  You probably mean: public function __construct($ammo)

>    {
>        $this->ammo = $ammo;
>    }
>
>    public function flingAt($target)
>    {
>        $target->flingAlert($this->ammo);

    Fatal error.  Unless you meant to create infinite recursion with
baboon::flingAt().

>    }
> }
>
>
> $me = new baboon($information);
> $you = new baboon();

    Since you didn't have a fallback definition in your __construct(),
this will throw a missing argument warning.  It will also then give an
undefined variable warning when it tries to define baboon::$ammo.

> $me->flingAt($you);

    Trying to work with an object here?  Since we're missing the
baboon::flingAlert() definition, I'm curious to see how the object is
handled.


    Oh, Friday....

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

--- End Message ---
--- Begin Message ---
On 15 September 2011 21:20, Matthew Pounsett <m...@conundrum.com> wrote:
> Anyone have any thoughts on what to look at?

php -m

look for XML

php --rf xml_parser_create

look for

Function [ <internal:xml> function xml_parser_create ] {

  - Parameters [1] {
    Parameter #0 [ <optional> $encoding ]
  }
}


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

--- End Message ---
--- Begin Message ---
On 2011/09/16, at 10:27, Richard Quadling wrote:

> On 15 September 2011 21:20, Matthew Pounsett <m...@conundrum.com> wrote:
>> Anyone have any thoughts on what to look at?
> 
> php -m
> php --rf xml_parser_create

Thanks.  This seems to reinforce that there's something wrong, but I don't feel 
like I know any more about what's broken. :)

> php -m
[PHP Modules]
Core
date
ereg
libxml
mysqlnd
pcre
Reflection
SPL
standard

[Zend Modules]

> php --rf xml_parser_create
Exception: Function xml_parser_create() does not exist


--- End Message ---
--- Begin Message ---
On 16 September 2011 23:18, Matthew Pounsett <m...@conundrum.com> wrote:
>
> On 2011/09/16, at 10:27, Richard Quadling wrote:
>
>> On 15 September 2011 21:20, Matthew Pounsett <m...@conundrum.com> wrote:
>>> Anyone have any thoughts on what to look at?
>>
>> php -m
>> php --rf xml_parser_create
>
> Thanks.  This seems to reinforce that there's something wrong, but I don't 
> feel like I know any more about what's broken. :)
>
>> php -m
> [PHP Modules]
> Core
> date
> ereg
> libxml
> mysqlnd
> pcre
> Reflection
> SPL
> standard
>
> [Zend Modules]
>
>> php --rf xml_parser_create
> Exception: Function xml_parser_create() does not exist
>
>

The xml_parser_create() function is in the XML extension, not in the
libxml extension.

php --re libxml
vs
php -d extension=php_xml.dll --re xml

Assuming php_xml.dll is available (may need to be .so rather than .dll
for non windows).

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

--- End Message ---
--- Begin Message ---
On 09/15/2011 01:20 PM, Matthew Pounsett wrote:
> 
> I seems to behaving issues with php5 on one particular server, and I haven't 
> been able to find the issue.  Basically, php says XML is enabled, but xml 
> functions are missing.
> 
>> php -i | grep "XML support"
> libXML support => active
> 
  Perhaps you need to install libxml[2]?

-- 
James Moe
jmm-list at sohnen-moe dot com

--- End Message ---
--- Begin Message ---
Hi,

Can someone help me understand how money_format() rounds numbers ?

<?php
  setlocale(LC_ALL, 'fr_FR.UTF-8');
  $price = 12.665;
  echo money_format('%i',$price);
  // 12.66 EUR, 12.67 EUR expected

  $price2 = 12.666;
  echo money_format('%i',$price2);
  // 12.67 EUR, ok

  echo round($price,2);
  // 12.67, ok
  echo round($price2,2);
  // 12.67, ok
?>

Misconfiguration ? Bug ?
Thanks !

Cyril

Config :
Debian Lenny, PHP 5.3.8

--- End Message ---
--- Begin Message ---
On 16 September 2011 15:58, Cyril Lopez <cy...@nethik.fr> wrote:
> Hi,
>
> Can someone help me understand how money_format() rounds numbers ?
>
> <?php
>  setlocale(LC_ALL, 'fr_FR.UTF-8');
>  $price = 12.665;
>  echo money_format('%i',$price);
>  // 12.66 EUR, 12.67 EUR expected
>
>  $price2 = 12.666;
>  echo money_format('%i',$price2);
>  // 12.67 EUR, ok
>
>  echo round($price,2);
>  // 12.67, ok
>  echo round($price2,2);
>  // 12.67, ok
> ?>
>
> Misconfiguration ? Bug ?
> Thanks !
>
> Cyril

Each locale can define its own rules regarding the number of digits to
show, but I can't see anything that covers the rounding.

OOI.

What do you get for 12.66999?

I'm on windows and there's no money_format function (due to a lack of
strfmon() function),


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

--- End Message ---
--- Begin Message ---
On 16 Sep 2011, at 15:58, Cyril Lopez wrote:

> Can someone help me understand how money_format() rounds numbers ?
> 
> <?php
>  setlocale(LC_ALL, 'fr_FR.UTF-8');
>  $price = 12.665;
>  echo money_format('%i',$price);
>  // 12.66 EUR, 12.67 EUR expected
> 
>  $price2 = 12.666;
>  echo money_format('%i',$price2);
>  // 12.67 EUR, ok
> 
>  echo round($price,2);
>  // 12.67, ok
>  echo round($price2,2);
>  // 12.67, ok
> ?>
> 
> Misconfiguration ? Bug ?

It's a direct mapping to the libc function, strfmon [1], and an equivalent C 
script gave the same result so it's not a bug in PHP. Locales can't define 
rounding rules, so it's not related to that.

Googling for strfmon rounding errors doesn't get any useful results, so either 
this is by design or it's never caused anyone a problem.

Solution... pass the number through round before going in to money_format.

-Stuart

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

--- End Message ---
--- Begin Message ---
Oops...

On 16 Sep 2011, at 16:36, Stuart Dallas wrote:

> On 16 Sep 2011, at 15:58, Cyril Lopez wrote:
> 
>> Can someone help me understand how money_format() rounds numbers ?
>> 
>> <?php
>> setlocale(LC_ALL, 'fr_FR.UTF-8');
>> $price = 12.665;
>> echo money_format('%i',$price);
>> // 12.66 EUR, 12.67 EUR expected
>> 
>> $price2 = 12.666;
>> echo money_format('%i',$price2);
>> // 12.67 EUR, ok
>> 
>> echo round($price,2);
>> // 12.67, ok
>> echo round($price2,2);
>> // 12.67, ok
>> ?>
>> 
>> Misconfiguration ? Bug ?
> 
> It's a direct mapping to the libc function, strfmon [1], and an equivalent C 
> script gave the same result so it's not a bug in PHP. Locales can't define 
> rounding rules, so it's not related to that.
> 
> Googling for strfmon rounding errors doesn't get any useful results, so 
> either this is by design or it's never caused anyone a problem.
> 
> Solution... pass the number through round before going in to money_format.
> 
> -Stuart

[1] http://lxr.php.net/opengrok/xref/PHP_5_3/ext/standard/string.c#5156

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


--- End Message ---
--- Begin Message ---
http://www.youtube.com/watch?v=5GpOfwbFRcs
 
LOLercopter

--- End Message ---
--- Begin Message ---
WOOT! ...you made my day with this :D thanks

Cheers!

-----Original Message-----
From: Daevid Vincent [mailto:dae...@daevid.com] 
Sent: Friday, September 16, 2011 1:30 PM
To: php-gene...@lists.php.net
Subject: [PHP] Episode 2 - All The Cool Kids Use Ruby 

http://www.youtube.com/watch?v=5GpOfwbFRcs
 
LOLercopter


--- End Message ---
--- Begin Message ---
On 11-09-16 02:30 PM, Daevid Vincent wrote:
http://www.youtube.com/watch?v=5GpOfwbFRcs

LOLercopter

That's just fantastic!

Have a great weekend.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
That was very funny. A perfect Friday item!

Bastien Koert
905-904-0334

On 2011-09-16, at 2:30 PM, "Daevid Vincent" <dae...@daevid.com> wrote:

> http://www.youtube.com/watch?v=5GpOfwbFRcs
> 
> LOLercopter

--- End Message ---
--- Begin Message ---
On 09/15/2011 08:50 PM, d...@php.net wrote:

Thanks X4!


-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---

Reply via email to