Re: sets
| From: | Zeev Suraski | Date: | Sun, 14 May 2000 22:54:29 +0000 |
| Subject: | Re: sets | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-18734@lists.php.net to get a copy of this message | ||
If they're well written, then those functions will be accepted. Generally any function which may be useful for the general public is happily accepted.
Zeev
At 14:33 06/05/2000 , Stig Venaas wrote:
Hi I'm writing an PHP4 application where I use sets a lot. The sets are arrays, but I only care what values I have in them, not about indices and ordering. I use the set operations union, intersection, subtraction a lot. I also need to check whether something is an element, that's easily done with array_in. I could do union with the array_merge function sort of, but I don't want duplicate values. It would help if had a function to remove duplicates though, but a specialised union would help. Would the following functions be accepted if I wrote them? array array_union(array array1, array array2) Creates an array that contains all values from array1 and array2 without any duplicates provided array1 and array2 don't have dups. array array_intersection(array array1, array array2) Creates an array that contains all values that exists both in array1 and array2. array array_subtraction(array array1, array array2) Creates an array that contains all values from array1 that is not in array2. The ordering will mostly be preserved, then they are also useful for "lists". Should they be named set_ rather than array_? So what do you say, is this useful? Stig -- Stig Venaas UNINETT -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- Zeev Suraski <zeev@zend.com> http://www.zend.com/