本文整理汇总了PHP中PKPString::substr_count方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPString::substr_count方法的具体用法?PHP PKPString::substr_count怎么用?PHP PKPString::substr_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPString
的用法示例。
在下文中一共展示了PKPString::substr_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Parse SQL content into individual SQL statements.
* @param $sql string
* @return array
*/
function &parseStatements(&$sql)
{
$statements = array();
$statementsTmp = explode($this->statementDelim, $sql);
$currentStatement = '';
$numSingleQuotes = $numEscapedSingleQuotes = 0;
// This method for parsing the SQL statements was adapted from one used in phpBB (http://www.phpbb.com/)
for ($i = 0, $count = count($statementsTmp); $i < $count; $i++) {
// Get total number of single quotes in string
$numSingleQuotes += PKPString::substr_count($statementsTmp[$i], "'");
// Get number of escaped single quotes
$numEscapedSingleQuotes += PKPString::regexp_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $statementsTmp[$i], $matches);
$currentStatement .= $statementsTmp[$i];
if (($numSingleQuotes - $numEscapedSingleQuotes) % 2 == 0) {
// Even number of unescaped single quotes, so statement must be complete
if (trim($currentStatement) !== '') {
array_push($statements, trim($currentStatement));
}
$currentStatement = '';
$numSingleQuotes = $numEscapedSingleQuotes = 0;
} else {
// The statement is not complete, the delimiter must be inside the statement
$currentStatement .= $this->statementDelim;
}
}
return $statements;
}