All pastes #124272 Raw Edit

Anonymous

public php v1 · immutable
·published 2006-08-09 22:55 UTC
rendered paste body
<?php/******Background*------------------I am trying to extract information from an ms excel file that containsINDIVIDUAL transactions of products in no order.I have created an array that contains the rows and columns of the ms excel file: $pickList[$j][$i]. Where $j represents the row no.and $i represents the column. The array has a total of 14 columnsof which I am using columns 11, 12, 13 and 14 (i.e $pickList[$j][11], $pickList[$j][12], $pickList[$j][13] and $pickList[$j][14] respectively).The array holds the following information about products:$pickList[$j][11] = Style number$pickList[$j][12] = Description$pickList[$j][13] = Quantity$pickList[$j][14] = PriceI want to calculate the TOTAL quantity of a product of a particular DESCRIPTION and then I want to sort by the style number. I need to sort by the description and NOT the style as 2 items may have the same style number, but descriptions will vary due to different size and colour combinations (the products are clothing items). */$productQtys = array();$j = 1;$total = 0;//Loop through rows:while($j < count($pickList)) {		//See if the product description in the current row has been previously added to $productQtys 	//If not then add relavent information		if (in_array($pickList[$j][12], $productQtys) == false)	{		$productQtys[] = $pickList[$j][12]; # Add description		$searchKey = array_search($pickList[$j][12], $productQtys); # Find search key to attach further information		$productQtys[$searchKey][1] = $pickList[$j][11]; # Add Pick number		$productQtys[$searchKey][2] = $pickList[$j][14]; # Add Price		}		//If product description is already in array, update the quantity 	//by adding the quantity in this row		if (in_array($pickList[$j][12], $productQtys) == true)	{		$searchKey = array_search($pickList[$j][12], $productQtys); # Find search key to attach further information		$productQtys[$searchKey][3] += $pickList[$j][13]; # Add row quantity to array.		}		$j++;		}//Display individual product quantities//======================================$i=0;while ($i < count($productQtys)){echo (.$productQtys[$i]."<br> QTY: ".$productQtys[$searchKey][3]."<hr>");		$i++;	}?>