PHP code example of singlequote / laravel-text-parser

1. Go to this page and download the library: Download singlequote/laravel-text-parser 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/ */

    

singlequote / laravel-text-parser example snippets


$values = [
    'user' => [
        'name' => [
            'first_name' => 'Foo',
            'last_name' => 'Bar'
        ],
        'email' => '[email protected]'
    ]
];

$input = "[user.name.first_name][user.name.last_name] - [user.email]";

$result = Parser::text($input)->values($values)->parse();
 php
Parser::text('Hello [who]')->values(['who' => 'world'])->parse(); // Hello world

Parser::text('Hello {who}')->values(['who' => 'world'])->tags(['{', '}'])->parse(); // Hello world

Parser::text('Hello [who]')->values(['who' => 'world'])->exclude(['who'])->parse(); // Hello [who]

Parser::text('Hello [what]')->values(['who' => 'world'])->aliases(['what' => 'who'])->parse(); // Hello world
 php
    $parser->values([]);
 php
    $parser->tags(['{','}']);
 php
    $parser->exclude(['key', 'key2']);
 php
    $parser->exclude(['alias', 'value key']);
 php
    $parser->exclude(['alias', 'value key']);