Login   Register  
PHP Classes
elePHPant
Icontem

File: expresion_parser.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Luis I. Larrateguy  >  Simplifica  >  expresion_parser.php  >  Download  
File: expresion_parser.php
Role: Auxiliary script
Content type: text/plain
Description: parser
Class: Simplifica
Simplify boolean expressions
Author: By
Last change:
Date: 2005-03-06 04:38
Size: 625 bytes
 

Contents

Class file image Download
<?php

function parseVariables(&$cadena,&$vars) {

    
$cadena "ABC~D + ~A~B~CD + A~BC~D";
    
$vars "ABCD";
    
$cant_vars strlen($vars);
    
    
$cadena str_replace(" ","",$cadena);    // saco espacios en blanco
    
$cadena strtoupper($cadena);            // paso a mayusculas
    
    
$reg_neg "(~[".$vars."])";            // Expresion regular para cambiar las negadas
    
$reg_no_neg "([".$vars."])";            // Expresion regular para cambiar las no negadas
    
    // Reemplazos
    
$cadena ereg_replace($reg_neg"0"$cadena);
    
$cadena ereg_replace($reg_no_neg"1"$cadena);
    
$cadena str_replace("+"," ",$cadena);
    
// all done

}


?>