1. Go to this page and download the library: Download yannickl88/css-tokenizer 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/ */
yannickl88 / css-tokenizer example snippets
use Yannickl88\Component\CSS\Tokenizer;
$tokens = (new Tokenizer())->tokenize('span { padding: 2px; margin: 2px; }');
$tokens = [
new Token(Token::T_WORD, 'span', 1, 1, 1, 4),
new Token(Token::T_WHITESPACE, ' ', 1, 5),
new Token(Token::T_OPENCURLY, '{', 1, 6),
new Token(Token::T_WHITESPACE, ' ', 1, 7),
new Token(Token::T_WORD, 'padding', 1, 8, 1, 14),
new Token(Token::T_COLON, ':', 1, 15),
new Token(Token::T_WHITESPACE, ' ', 1, 16),
new Token(Token::T_WORD, '2px', 1, 17, 1, 19),
new Token(Token::T_SEMICOLON, ';', 1, 20),
new Token(Token::T_WHITESPACE, ' ', 1, 21),
new Token(Token::T_WORD, 'margin', 1, 22, 1, 27),
new Token(Token::T_COLON, ':', 1, 28),
new Token(Token::T_WHITESPACE, ' ', 1, 29),
new Token(Token::T_WORD, '2px', 1, 30, 1, 32),
new Token(Token::T_SEMICOLON, ';', 1, 33),
new Token(Token::T_WHITESPACE, ' ', 1, 34),
new Token(Token::T_CLOSECURLY, '}', 1, 35),
];
$token->type; // for the type
$token->chars; // for the characters
$token->lines; // array containing start and (sometimes) end line
$token->offsets; // array containing start and (sometimes) end offset
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.