Garayed.com  

Go Back   Garayed.com > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-2006, 10:37 AM
Nico
 
Posts: n/a
Default Two functions and one problem


Hi,

I've created the following sample php code.

Elements<br>
<?php
$elements[1]="element1";
$elements[2]="element2";
$elements[3]="element3";
$elements[4]="element4";
$elements[5]="element5";
?>
Combinations
<?php
$combinations[1][1]="element1"; // Combination of element 1 with element
2
$combinations[1][2]="element2";
$combinations[2][1]="element3"; // Combination of element 1 with element
3
$combinations[2][2]="element1";
$combinations[3][1]="element4"; // Combination of element 1 with element
4
$combinations[3][2]="element1";
$combinations[4][1]="element5"; // Combination of element 1 with element
5
$combinations[4][2]="element1";
?>

I'd like to define two simple functions:
countcombinations(a,...;b,...)
listcombinations(a,...;b,...)

The first function "countcombinations(a,...;b,...)" should count how many
combinations exist in which "a" and "..." are included and "b" and "..."
are not included.

Example
countcombinations(element1;element2,element3)
Result: 2 ("element1 combined with element4" and "element1 combined with
element5")

The second function "listcombinations(a,...;b,...)" should list the elements
combined with "a" and "...", excluding from the list the elements "b" and
"...".

Example
listcombinations(element1;element2,element3)
Result: element4, element5

I've some difficult in defining this two functions.
Can you help me please?
Many thanks.

Best,
Nico
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:08 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.