Details
Math-Expression-to-HTML
Produce html code from the mathematic expression string
Demo Version
Visit following link and check demo in forum.
Demo
Usage
First include the mathexphtml.php
class in your file, and use the class as following to generate the HTML for the math expressions:
$expression = "a=sum(i=1,3,23.5{vec}-(((cos(2+?/2)+asd9)^2)/4.5+sin(0.5?))/(20.06+?*(16))^2-26)";
$parser = new mathExpHtml($expression);
$parser->printTokens();
echo $parser->getHtml();
Features
Algorythm is very simple.
-
String is tokenized using `preg_split` into array of tokens,
-
Token types are value, alpha-numeric and operator.
-
Alpha numeric represents as a variable or function name.
-
There are some known functions such as summation sign sum(i=1, 5).
-
First tokens are simplify into simple expression inside the parenthesis.
-
Nested parenthesis are allowed.
-
Simple inside () are convert into html code using predefined css classes.
-
Precedence are common as following order, ^, *,/,+.-.
-
Multiple expressions of () may connected without operator eg., (3+a/4)(sin(0.5*?))
-
Vector variable can be used in written form enclosed with cali-bracket eg., {vec}
Contact
Contact me for comercial use via mail winaungcho@gmail.com.
|
Name: |
How to Use a PHP Math Expression Parser to Convert a Math Expression to HTML |
Base name: |
math-expression-to-h |
Description: |
Render mathematics expressions on an HTML page |
Version: |
- |
PHP version: |
5 |
Licenses: |
Custom (specified in a license file)
GNU General Public License (GPL) |
|
|
|
Screenshots |
|
November 2022
Number 2 |
Some applications need to display mathematical expressions on Web pages in a way that professionals in mathematics are used to seeing those expressions.
A mathematical expression can be displayed on a Web page in several ways.
This package can render a mathematical expression using regular HTML.
Manuel Lemos |
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.
|
Files |
|
|
Files |
|