StringHelper::startsWith PHP Method

startsWith() public method

public startsWith ( string $str ) : boolean
$str string
return boolean
    public function startsWith($str)
    {
        return mb_substr($this->value, 0, mb_strlen($str)) == $str;
    }

Usage Example

Example #1
0
 /**
  * Returns stream only including
  * lines from the original stream which don't start with any of the
  * specified comment prefixes.
  *
  * @param null $len
  * @return mixed the resulting stream, or -1
  *               if the end of the resulting stream has been reached.
  *
  */
 public function read($len = null)
 {
     if (!$this->getInitialized()) {
         $this->_initialize();
         $this->setInitialized(true);
     }
     $buffer = $this->in->read($len);
     if ($buffer === -1) {
         return -1;
     }
     $lines = explode("\n", $buffer);
     $filtered = array();
     $commentsSize = count($this->_comments);
     foreach ($lines as $line) {
         for ($i = 0; $i < $commentsSize; $i++) {
             $comment = $this->_comments[$i]->getValue();
             if (StringHelper::startsWith($comment, ltrim($line))) {
                 $line = null;
                 break;
             }
         }
         if ($line !== null) {
             $filtered[] = $line;
         }
     }
     $filtered_buffer = implode("\n", $filtered);
     return $filtered_buffer;
 }
All Usage Examples Of StringHelper::startsWith