PHP version of the truth table-truevaluetable expression, truth table logical Expression _php Tutorial

Source: Internet
Author: User
Tags uppercase letter

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 ' (" " " "= (2, (=0;<;++[]= ("%0{}d ", [[]=] ([=] "([] =" "[]=[]." =". ([].";" ("\ $varTotal 3[] =".. ";" (= = (==[]=0 " " " "?>
{$v}Results
". $v 1. "". $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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.