- ltrim: documentation ( source)
- substr_count: documentation ( source)
- var_dump: documentation ( source)
- strpos: documentation ( source)
- trim: documentation ( source)
<?php
$string = ' - "True Monitoring Range" #29 - windows checker units"';
function hasInlineCommentInSequence($line)
{
if (strpos(ltrim($line), '-') !== 0) {
return false;
}
$trimmed = trim($line);
$hashPos = strpos($trimmed, ' #');
if ($hashPos === false) {
return false;
}
$count = substr_count($trimmed, '"', 0, $hashPos);
return ($count % 2) === 0;
}
var_dump(hasInlineCommentInSequence($string));