public function PARSEENTRIES::explodeString in Bibliography Module 7
Same name and namespace in other branches
- 5 bibtexParse/PARSEENTRIES.php \PARSEENTRIES::explodeString()
- 6.2 modules/bibtexParse/PARSEENTRIES.php \PARSEENTRIES::explodeString()
- 6 bibtexParse/PARSEENTRIES.php \PARSEENTRIES::explodeString()
- 7.3 plugins/biblio_style/bibtex/PARSEENTRIES.php \PARSEENTRIES::explodeString()
- 7.2 modules/bibtexParse/PARSEENTRIES.php \PARSEENTRIES::explodeString()
This function works like explode('#',$val) but has to take into account whether the character # is part of a string (i.e., is enclosed into "..." or {...} ) or defines a string concatenation as in @string{ "x # x" # ss # {xx{x}x} }.
1 call to PARSEENTRIES::explodeString()
- PARSEENTRIES::removeDelimitersAndExpand in modules/
bibtexParse/ PARSEENTRIES.php - Remove enclosures around entry field values. Additionally, expand macros if flag set.
File
- modules/
bibtexParse/ PARSEENTRIES.php, line 413
Class
- PARSEENTRIES
- // Parse a file $parse = NEW PARSEENTRIES(); $parse->expandMacro = TRUE; // $array = array("RMP" =>"Rev., Mod. Phys."); // $parse->loadStringMacro($array); // $parse->removeDelimit = FALSE; // …
Code
public function explodeString($val) {
$openquote = $bracelevel = $i = $j = 0;
while ($i < strlen($val)) {
if ($val[$i] == '"') {
$openquote = !$openquote;
}
elseif ($val[$i] == '{') {
$bracelevel++;
}
elseif ($val[$i] == '}') {
$bracelevel--;
}
elseif ($val[$i] == '#' && !$openquote && !$bracelevel) {
$strings[] = substr($val, $j, $i - $j);
$j = $i + 1;
}
$i++;
}
$strings[] = substr($val, $j);
return $strings;
}