diff --git a/index.php b/index.php index e384358..278f8de 100644 --- a/index.php +++ b/index.php @@ -62,12 +62,6 @@

MathML Output

- - - x¯ - 1 - -
diff --git a/utils/espresso.php b/utils/espresso.php index 692b486..b7cc29b 100644 --- a/utils/espresso.php +++ b/utils/espresso.php @@ -8,15 +8,41 @@ function int2bin($number, $numbits){ function getMathML($output) { $lines = explode("\n", $output); - foreach($lines as $line){ - $pos = strpos($line,$needle); - if($pos === false) { - // string needle NOT found in haystack + // get the number of terms in the output + $terms = substr(strstr($lines[2], ' '), 1); + $math = 'f='; + for ($i = 3; $i < $terms + 3; $i++) + { + $term = strstr($lines[$i], ' ', true); + for($j = 0; $j < strlen($term); $j++){ + $char = $term{$j}; + $num = $j+1; + switch($char) { + case '0': + $math .= "x¯$num"; + break; + case '1': + $math .= "x$num"; + break; + case '-': + break; + } } - else { - // string needle found in haystack + if($i < $terms + 2) { + $math .= '+'; } } + $math .= ''; + return $math; +// foreach($lines as $line){ +// $pos = strpos($line,$needle); +// if($pos === false) { +// // string needle NOT found in haystack +// } +// else { +// // string needle found in haystack +// } +// } } $inputs = $_POST['inputs']; //convert minterms to array of numbers @@ -58,7 +84,7 @@ function getMathML($output) { $output = shell_exec("../bin/espresso $tempfname"); // close temporary file fclose($temp); - + $math = getMathML($output); echo "
$output
"; - + echo $math; ?> \ No newline at end of file