This draft of the documentation remains immature. While we have made attempt to be thorough and accurate, you may encounter errors. If you discover any deficiencies, please let us know at info@kingdesk.com
This page is a subset of the documentation of the functionality provided by the PHP Parser project.parseText Get Methods
get_all()
Description
array get_all ( )
A method of class parseText. Returns an array of all tokens, regardless of type. Unlike the parseHTML class, parseText tokens are not subject to locking or unlocking.
Return Values
Returns an array of all tokens, regardless of type.
Examples
<?php
$text = "¿sample email@example.com?";
include('path/to/php-parser.php');
$parsedText = new parseText();
$parsedText->load($text);
$all = $parsedText->get_all();
foreach($all as &$each) {
$each["value"] = $each["value"]."_";
}
$parsedText->update($all);
$text = $parsedText->unload();
echo $text; // ¿_sample_ _email@example.com_?_
?>
get_spaces()
Description
array get_spaces ( )
A method of class parseText. Returns an array of all tokens, of type “space”. Unlike the parseHTML class, parseText tokens are not subject to locking or unlocking.
Return Values
Returns an array of all tokens, of type “space”.
Examples
<?php
$text = "¿sample email@example.com?";
include('path/to/php-parser.php');
$parsedText = new parseText();
$parsedText->load($text);
$spaces = $parsedText->get_spaces();
foreach($spaces as &$space) {
$space["value"] = "";
}
$parsedText->update($spaces);
$text = $parsedText->unload();
echo $text; // ¿sampleemail@example.com?
?>
get_punctuation()
Description
array get_punctuation ( )
A method of class parseText. Returns an array of all tokens, of type “punctuation”. Unlike the parseHTML class, parseText tokens are not subject to locking or unlocking.
Return Values
Returns an array of all tokens, of type “punctuation”.
Examples
<?php
$text = "¿sample email@example.com?";
include('path/to/php-parser.php');
$parsedText = new parseText();
$parsedText->load($text);
$punctuations = $parsedText->get_punctuation();
foreach($punctuations as &$punctuation) {
$punctuation["value"] = "";
}
$parsedText->update($punctuations);
$text = $parsedText->unload();
echo $text; // sample email@example.com
?>
get_words()
Description
array get_words ( [ int $abc = 0 [ , int $caps = 0 ] ] )
A method of class parseText. Returns an array of all tokens, of type “word”. Unlike the parseHTML class, parseText tokens are not subject to locking or unlocking.
Parameters
- abc
- OPTIONAL. Prohibits, allows or requires an alpha-only match. Allowed values are:
- –1 (prohibit)
- 0 (allow – default)
- 1 (require)
- caps
- OPTIONAL. Prohibits, allows or requires an capital-only match. Allowed values are:
- –1 (prohibit)
- 0 (allow – default)
- 1 (require)
Return Values
Returns an array of all tokens, of type “word”.
Examples
<?php
$text = "¿sample email@example.com?";
include('path/to/php-parser.php');
$parsedText = new parseText();
$parsedText->load($text);
$words = $parsedText->get_words();
foreach($words as &$word) {
$word["value"] = "";
}
$parsedText->update($words);
$text = $parsedText->unload();
echo $text; // ¿ email@example.com?
?>
get_other()
Description
array get_other ( )
A method of class parseText. Returns an array of all tokens, of type “other”. Unlike the parseHTML class, parseText tokens are not subject to locking or unlocking.
Return Values
Returns an array of all tokens, of type “other”.
Examples
<?php
$text = "¿sample email@example.com?";
include('path/to/php-parser.php');
$parsedText = new parseText();
$parsedText->load($text);
$others = $parsedText->get_other();
foreach($others as &$other) {
$other["value"] = "";
}
$parsedText->update($others);
$text = $parsedText->unload();
echo $text; // ¿sample ?
?>

