function makeLists($dataArray) { // will return this array. $lensArray[id][n], where id is the lens id and n is each row of power variations it comes in $lensArray = array(); $currentN = 0; //this will count the rows for each lens id $currentLensID = 0; //powerRow will be one table row of lens powers foreach ($dataArray as $powerRow) { $lensID = $powerRow['lensID']; //echo "$lensID : $currentN <br/>"; if ($lensID != $currentLensID) { $currentN = 0; $currentLensID = $lensID; } if ($powerRow['baseCurve']) { $powerRow['baseCurve'] = parseMMData($powerRow['baseCurve']); } if ($powerRow['diameter']) { $powerRow['diameter'] = parseMMData($powerRow['diameter']); } if ($powerRow['sphere']) { $powerRow['sphere'] = parsePowerData($powerRow['sphere']); } if ($powerRow['cylinder']) { $powerRow['cylinder'] = parsePowerData($powerRow['cylinder']); } if ($powerRow['axis']) { $powerRow['axis'] = parseIntegerData($powerRow['axis']); } if ($powerRow['addPwr']) { $powerRow['addPwr'] = parsePowerData($powerRow['addPwr']); } if ($powerRow['colors_enh']) { $powerRow['colors_enh'] = explode(",", $powerRow['colors_enh']); } if ($powerRow['colors_opq']) { $powerRow['colors_opq'] = explode(",", $powerRow['colors_opq']); } $lensArray[$powerRow['lensID']][$currentN] = $powerRow; $currentN++; } //echo "<p> </p>"; //print_r($lensArray); return $lensArray; }
function makeAllList($string) { $string = trim($string, ","); $string = preg_replace_callback("/((\\d+(\\.\\d*)?)|\\.\\d+)([0-9]*)/", 'callbackFunction', $string); $numArray = parseMMData($string); //an array of individual values $array = explode(",", $string); // an array of chunks which may include ranges $array = array_filter(array_map('trim', $array)); $numArray = array_filter(array_map('trim', $numArray)); $array = array_unique($array); //get rid of duplicates usort($numArray, "ascSorter"); usort($array, "ascSorter"); $string = shortestString(implode(", ", $array), implode(", ", $numArray)); return $string; }