1. Go to this page and download the library: Download mojahed/mparser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mojahed / mparser example snippets
$data = [
// Your data array here
];
$string = "Your input string here";
$result = MParser::parse($string, $data);
$data = ['numbers' => '1-2-3-4-5'];
$string = "The second number is: <<numbers>[exp(-, 2)]>.";
// Result: "The second number is: 2."
$data = ['word' => 'hello'];
$string = "The first three letters are: <<word>[cut(1, 3)]>.";
// Result: "The first three letters are: hel."
$data = ['word' => 'hello'];
$string = "The last three letters are: <<word>[cut_back(3)]>.";
// Result: "The last three letters are: llo."
$data = ['word' => 'hello'];
$string = "The reversed word is: <<word>[reverse()]>.";
// Result: "The reversed word is: olleh."
$data = ['number' => 5];
$string = "The sum is: <<number>[sum(10)]>.";
// Result: "The sum is: 15."
$data = ['number' => 15];
$string = "The difference is: <<number>[sub(10)]>.";
// Result: "The difference is: 5."
$data = ['number' => 5];
$string = "The result is: <<number>[mul(3)]>.";
// Result: "The result is: 15."
$data = ['number' => 15];
$string = "The result is: <<number>[div(3)]>.";
// Result: "The result is: 5."
$data = ['number' => 2];
$string = "The result is: <<number>[power(3)]>.";
// Result: "The result is: 8."
$data = ['word' => 'hello'];
$string = "The uppercase word is: <<word>[upper()]>.";
// Result: "The uppercase word is: HELLO."
$data = ['word' => 'HELLO'];
$string = "The lowercase word is: <<word>[lower()]>.";
// Result: "The lowercase word is: hello."
$data = ['word' => 'hello'];
$string = "The capitalized word is: <<word>[capitalize()]>.";
// Result: "The capitalized word is: Hello."
$data = ['sentence' => 'The quick brown fox'];
$string = "The modified sentence is: <<sentence>[replace(quick, lazy)]>.";
// Result: "The modified sentence is: The lazy brown fox."
$data = ['word' => 'hello'];
$string = "The length of the word is: <<word>[length()]>.";
// Result: "The length of the word is: 5."
$data = ['word' => 'hello'];
$string = "The concatenated word is: <<word>[concat( world)]>.";
// Result: "The concatenated word is: hello world."
$data = ['word' => 'hello'];
$string = "The length of hello world is: <<word>[concat( world)][upper()][length()]>.";
// Result: "The length of hello world is: 11."
class ChildParser extends MParser
{
function __construct($string, array $dataset)
{
parent::__construct($string, $dataset);
}
public function _reverse($token, $args)
{
return strrev($token);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.