This table is inside a database
TID Products
1 1,2,5
2 2,4
3 2,3
4 1,2,4
5 1,3
6 2,3
7 1,3
8 1,2,3,5
9 1,2,3
this table is created by combinations of itemsets, for now only 2 itemsets but eventually 3, 4, 5 and so on. As you can see the Sup count counts the coincidences in the Products table of the Itemset that is in that row.
ItemSet Sup. count
1,2 4
1,3 2
1,4 0
1,5 0
2,3 4
2,4 2
2,5 1
3,4 0
3,5 1
4,5 0
for($i = 0; $i < $count_itemsets; $i++){
for($j = 0; $j < $count_productrow; $j++){
$string = $productrow[$j];
$myArray = explode(',', $string);
this turns the string into an array example the first product {1,2,5}
$arr_expl_itemset = explode(',',$itemset[$i]);
this explodes itemset to also make it into an array example the first ItemSet row {1,2}
$count_explode = count($arr_expl_item);
this counts the length of the new array $arr_expl_itemset
for ($x = 0; $x < $count_explode - 1; $x++){
array_splice($arr_expl_item,$count_explode - 1,0,"&");
}
echo $arr_expl_item;
this for loop is where I want to add new elements without erasing the old ones. The new element that I want to add is the ampersand to make a array that looks like this:
1 & 2 & 5 that is why I am counting the array to minus 1 so that the last element is not an ampersand. All this to then convert to a string which would be $arr_expl_item_STRING = 1 & 2 & 5;
this is where I am stuck. I don't really know if this would work with preg_match but I've been reading and to do an OR statement the code would be like this:
/*if(preg_match("/(bad|naughty|other)/i", $data)){
//one of these string found
}*/
So I was thinking if I wanted to do a comparative with AND I would do it the way that I explained before.
if (preg_match('/($arr_expl_item_STRING)/i', $string, $m)) {
$result_support[$i] = $result_support[$i] + 1;
I want to count the numbers in the array so that i can look for {1,3} in the products column where the string is {1,3}, {1,2,3}, {1,2,3,5} and so on. if I do a boundary to look for a specific substring the matches will not work and if I look for coincidences it wont work when I get to two digit numbers like 12 or more since 1 and 2 would be found again.
}
}
}