Blouse Size Calculator
array(‘bust’ => ’33/84′, ‘waist’ => ’27/69′, ‘armhole’ => ’15/38′, ‘shoulder’ => ‘13.5/34’), ‘S’ => array(‘bust’ => ’35/89′, ‘waist’ => ’29/74′, ‘armhole’ => ’16/41′, ‘shoulder’ => ’14/35′), ‘M’ => array(‘bust’ => ’37/94′, ‘waist’ => ’31/79′, ‘armhole’ => ’17/43′, ‘shoulder’ => ‘14.5/36’), ‘L’ => array(‘bust’ => ’39/99′, ‘waist’ => ’33/84′, ‘armhole’ => ’18/46′, ‘shoulder’ => ’15/38′), ‘XL’ => array(‘bust’ => ’41/104′, ‘waist’ => ’35/89′, ‘armhole’ => ’19/49′, ‘shoulder’ => ‘15.5/40’), ‘XXL’ => array(‘bust’ => ’43/109′, ‘waist’ => ’37/94′, ‘armhole’ => ’20/52′, ‘shoulder’ => ’16/42′), ‘3XL’ => array(‘bust’ => ’45/114′, ‘waist’ => ’39/99′, ‘armhole’ => ’21/55′, ‘shoulder’ => ‘16.5/44’), ‘4XL’ => array(‘bust’ => ’47/119′, ‘waist’ => ’41/104′, ‘armhole’ => ’22/58′, ‘shoulder’ => ’17/46′), ‘5XL’ => array(‘bust’ => ’49/124′, ‘waist’ => ’43/109′, ‘armhole’ => ’23/61′, ‘shoulder’ => ‘17.5/48’) ); // Function to calculate blouse size function calculateBlouseSize($bust, $waist, $armhole, $shoulder) { global $sizeChart; $closestSize = null; $minDifference = PHP_INT_MAX; foreach ($sizeChart as $size => $measurements) { $bustDiff = abs($bust – (float)str_replace(‘/’, ‘.’, $measurements[‘bust’])); $waistDiff = abs($waist – (float)str_replace(‘/’, ‘.’, $measurements[‘waist’])); $armholeDiff = abs($armhole – (float)str_replace(‘/’, ‘.’, $measurements[‘armhole’])); $shoulderDiff = abs($shoulder – (float)str_replace(‘/’, ‘.’, $measurements[‘shoulder’])); $totalDifference = $bustDiff + $waistDiff + $armholeDiff + $shoulderDiff; if ($totalDifference < $minDifference) { $minDifference = $totalDifference; $closestSize = $size; } } return $closestSize; } // Handle form submission if ($_SERVER["REQUEST_METHOD"] == "POST") { $bust = $_POST["bust"]; $waist = $_POST["waist"]; $armhole = $_POST["armhole"]; $shoulder = $_POST["shoulder"]; $blouseSize = calculateBlouseSize($bust, $waist, $armhole, $shoulder); echo "Your recommended blouse size is: ” . strtoupper($blouseSize) . “
“; } ?>