parseText Get Methods

This draft of the doc­u­men­ta­tion remains imma­ture. While we have made attempt to be thor­ough and accu­rate, you may encounter errors. If you dis­cover any defi­cien­cies, please let us know at info@​kingdesk.​com

This page is a sub­set of the doc­u­men­ta­tion of the func­tion­al­ity pro­vided by the PHP Parser project.

parse­Text Get Methods

get_​all()

Descrip­tion

array get_all ( )

A method of class parse­Text. Returns an array of all tokens, regard­less of type. Unlike the parse­HTML class, parse­Text tokens are not sub­ject to lock­ing or unlocking.

Return Val­ues

Returns an array of all tokens, regard­less of type.

Exam­ples


<?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_?_
?>

return to top

get_​spaces()

Descrip­tion

array get_spaces ( )

A method of class parse­Text. Returns an array of all tokens, of type “space”. Unlike the parse­HTML class, parse­Text tokens are not sub­ject to lock­ing or unlocking.

Return Val­ues

Returns an array of all tokens, of type “space”.

Exam­ples


<?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?
?>

return to top

get_​punctuation()

Descrip­tion

array get_punctuation ( )

A method of class parse­Text. Returns an array of all tokens, of type “punc­tu­a­tion”. Unlike the parse­HTML class, parse­Text tokens are not sub­ject to lock­ing or unlocking.

Return Val­ues

Returns an array of all tokens, of type “punctuation”.

Exam­ples


<?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
?>

return to top

get_​words()

Descrip­tion

array get_words ( [ int $abc = 0 [ , int $caps = 0 ] ] )

A method of class parse­Text. Returns an array of all tokens, of type “word”. Unlike the parse­HTML class, parse­Text tokens are not sub­ject to lock­ing or unlocking.

Para­me­ters

abc
OPTIONAL. Pro­hibits, allows or requires an alpha-​​only match. Allowed val­ues are:
  • –1 (pro­hibit)
  • 0 (allow – default)
  • 1 (require)
caps
OPTIONAL. Pro­hibits, allows or requires an capital-​​only match. Allowed val­ues are:
  • –1 (pro­hibit)
  • 0 (allow – default)
  • 1 (require)

Return Val­ues

Returns an array of all tokens, of type “word”.

Exam­ples


<?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?
?>

return to top

get_​other()

Descrip­tion

array get_other ( )

A method of class parse­Text. Returns an array of all tokens, of type “other”. Unlike the parse­HTML class, parse­Text tokens are not sub­ject to lock­ing or unlocking.

Return Val­ues

Returns an array of all tokens, of type “other”.

Exam­ples


<?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 ?
?>

return to top