I am writing a function to convert a table of numbers from decimal e.g. (4.25) to fractional form (4 1/2) Certain columns of the table need to be ignored because they contain a letter or there is no fractional equivalent. The fractional form is to a 1/16 accuracy. (You can see a sample table here: [url=http://www.piping-designer.com/pages/flanges/fl150wnrtj.php]http://www.piping-designer.com/pages/flanges/fl150wnrtj.php[/url]) I wrote the following function. My problem is this, when I search for items that are not listed in the array, it returns just the integer and that is unacceptable for this project. I have tried creating a fraction with 16ths as a denominator and reducing the fraction using the Euclidian algorithm but I reached same problem when the fraction would not reduce. How can I get the function to exit if $key is not found in the array? Here's the code: [code]<?php function fraction($value){ // Define arrray that we are checking against $values = array('1/16' => .0625, '1/8' => .125, '3/16' => .1875, '1/4' => 0.25, '5/16' => .3125, '3/8' => .375, '7/16' => .4375, '1/2' => .5, '9/16' => .5625, '5/8' => .625, '11/16' => .6875, '3/4' => .75, '13/16' => .8125, '7/8' => .875, '15/16'=>.9375); if (eregi('[[:alpha:]]', $value)) { return $value; //contains any letter letter we're done here }else{ //There are no letters so we continue $intnum=floor($value); //take the value and round it down $dec = $value - $intnum; //Get the decimal portion of the original value $key = array_search($dec, $values,strict); //search the array for the decimal value if ($intnum < 1){ //if the value is less than zero, then we will return just a fraction $value = $key; }else{ //otherwise we will return the integer and the fraction $value = $intnum." ".$key; } return $value; } } ?>[/code] EDIT: Tried to fix formatting but failed horribly