The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed Provide the project number Insufficient form parameters: you forgot to fill in some field/s
 
member picmember pic
 
Snippets of A
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Share on MySpace

PHP: Match Each Array Item Once With All The Other Array Items

Snippet: Identification Number »   Snippet: Inclusion syntax »
Visitors: 14,469 Tagged by its author as: Programming Php Characters (in origin): 1,979 (pages: ~ 1)
Author: Em@il Permalink Cast your vote for this topic Printable version
OBJECTIVE: given an array, return all the combinations of each item once with each other, without duplicates.  
function arrayCombinator(&$array){
if(!is_array($array)){return $array;/*or php sizeof() matches Strings too!*/};
$output=array(); $L=sizeof($array); $i1=-1;
while(++$i1<$L){
$compare=array_shift($array);
	$L2=sizeof($array)-$i1; $i2=-1;
		while(++$i2<$L2){/*kernel is here:*/ $output[]=array($compare, $array[$i2]); }
array_push($array, $compare);
}
return $output;
/*keep comment to use freely:
http://www.fullposter.com/?1*/}
Remove colors  
INPUTS: an array.  
 
RETURNS: an array.  
 
CAVEATS: the input array is affected, but eventually returned unaltered unless you perform operations within the kernel that manipulate and alter the data. To avoid this, remove the pointer from the function signature namely the & sign before the input argument.  
 
Within the section dubbed "kernel" (in a comment), you may add custom code, namely remove entirely all the $output variable related parts, and manipulate directly the
$compare
$array[$i2]
Remove colors items with code of your own: in fact, those items are your combinations in progress.  
 
You may even consider producing maps: if you have to manipulate repeatedly some input array of, say, 30 entries, produce first an output with an array in the range(0,29) (whereas 29 is 30-1) and pass it to this function; then, to grab the combinations from the input array you may just use the indexes of the firstly produced array as a map (arguably to serialize for later use): so you run the function only once - in a lifetime, at least for all arrays whose length is either equal or inferior to 30.  
 
Example:
$afoo=array(0,1,2,3,4,5,6);
print_r( arrayCombinator($afoo) );
Remove colors
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss

Cast your vote for this topic

To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Are you the author of this topic and do you want to append quickly more text? click here
Other topics
This subscriber has a blog too: Read the blog: 57 Shoutbox: 103 reviews: 153
Visitors: 14,469
Overall visits to all the topics: 5,062,245
Daily average (Calculated from the website subscription day): 2,078.10
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Php
Current order: normal
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(4), Books(236), Boxing(2), Critical Reviews and Essays(4), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(2), Methematics(2), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(7), Poetry(1), Programming(4), Programming Ajax(2), Programming Javascript(82), Programming Php(52), Psychology(1), Quotes(1), Religion Esoterica and Spirituality(13), Scientifical Reviews(4), Self Improvement(1), Sport Activities and Apparels(1), Tarots(1)
Showing topics: 1, 10
Available total: 450
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
In The Land Of Nod, East Of Eden: Where Fire Does Not Play. A Biblical Exegesis. Identification Number: 467 Visitors: 365 Analisi comparata dei tre pesi massimi con maggior numero di flash ko dal 1969 Identification Number: 466 Visitors: 492 Fighting Competently: Anticipation, And Remember It's In His Eyes Identification Number: 465 Visitors: 625 La Musa Segreta: Superiorità Onnipervasiva Della Boxe Identification Number: 464 Visitors: 1,646 Ha Senso Il Doping Sportivo? Effetto Matteo Nello Sport E Business Sportivo Identification Number: 463 Visitors: 1,635 The Musicians Within The Music Box And Other Hereafter Stories Identification Number: 462 Visitors: 3,059 Freud And Jung In A Nutshell: Three Or So Shots At Psychoanalysis For Dummies Identification Number: 461 Visitors: 4,503 Division The Math Of Gods: Ambiguities Of Antanairesis And New Math Operations Identification Number: 460 Visitors: 4,713 The Meaning Of Cruelty Identification Number: 459 Visitors: 5,177 Dÿanèra Ad Eleusi: La Folgorazione Ontologica: Il Pensare Sistematico E Non Identification Number: 458 Visitors: 5,995
External services
This page of this subscriber uses external services: Hide