PHP version of the truth table-truevaluetable expression, truth table logical expression
Phperror_reporting(E_all& ~E_notice); $expression=$_get[' truetable '];//reading input box data if(!Empty($_get[' Truetable '])){ $expression=Strtoupper($expression);//Replace the lowercase letter entered with an uppercase letter $EXPRESSIONARR=Str_split($expression);//convert $expression to an array foreach($EXPRESSIONARR as $v){//Put the letters in the $varTotal array if($v>= ' A ' &&$v<= ' Z '){ $varTotal[]=$v; } } $varTotal=Array_unique($varTotal);//remove repeated letters from the $vartotal array Sort($varTotal);//alphabetical Ordering of $varTotal arrays $varTotal 1=Preg_replace("/([A-z])/", "$\\1",$varTotal);//$varTotal 1 The letters in the array become variables $maxN=Count($varTotal); //$EXPRESSIONARR = Preg_replace ("/([A-z])/", "$\\1", $EXPRESSIONARR);//$EXPRESSIONARR The letters in the array become variables $newExpression=implode('',$EXPRESSIONARR);//$expressionArr array becomes a string//echo $newExpression. "
"; $newExpression=Preg_replace("/([A-z])-([A-z])/", "!\\1|\\2",$newExpression); $newExpression=Preg_replace("/(\ (. *?\))-([A-z])/", "!\\1|\\2",$newExpression); $newExpression=Preg_replace("/(\ (. *?\)), (. *?) /","!\\1|\\2 ",$newExpression); $newExpression=Preg_replace("/([A-z]), (. *?) /","!\\1|\\2 ",$newExpression); $EXPRESSIONARR=Str_split($newExpression);//convert $expression to an array $EXPRESSIONARR=Preg_replace("/([A-z])/", "$\\1",$EXPRESSIONARR); $newExpression=implode('',$EXPRESSIONARR); //echo $newExpression; }?> <title>Truth Table Query 1.0 by: Xiao Zhen</title> $_get[' truetable ']?> "/>
[Description: Disjunction (|), Hop (&), non (!), implied (-), equivalent (=)]
Echo ; if Empty $_get ])){ foreach $varTotal as $v ){ Echo ; } Echo ; $result POW $maxN ); for $i $i $result $i ){ $resultN $i sprintf $maxN Decbin $i )); $resultN $i Str_split $resultN $i ]); } foreach $resultN as $k $v ){ Echo ; foreach $resultN $k as $k 1 $v 1 ){ Echo ; $varTotal 2 $k 1 $varTotal 1 $k 1 $v 1 ; // echo $varTotal 2[$k 1]. " "; Eval $varTotal 2 $k 1 ); } // echo $newExpression; Eval $newExpression ); foreach $varTotal 3 as $k 2 $v ){ if $v NULL ){ $varTotal 3 $k 2 ; } } Echo ; Echo ; } // Print_r ($varTotal 3); }
PHP "
"(! ([' Truetable ' ("
{$v} | " "
Results | "= (2, (=0;<;++[]= ("%0{}d ", [[]=] ([=]
"([] ="
". $v 1. " | "[]=[]." =". ([].";" ("\ $varTotal 3[] =".. ";" (= = (==[]=0 "
". $varTotal 3 [$k]. " | " "
"?>
http://www.bkjia.com/PHPjc/963545.html www.bkjia.com true http://www.bkjia.com/PHPjc/963545.html techarticle PHP version of the truth table-truevaluetable expression, truth table logical expression? PHP error_reporting (e_all ~ e_notice); $expression = $_get [' truetable ']; /Read input box data ...