public mark ( string $search, string $text, string $name = 'strong', array $attributes = [], boolean $escape = false ) : string | ||
$search | string | 検索文字列 |
$text | string | 検索対象文字列 |
$name | string | マーク用タグ(初期値 : strong) |
$attributes | array | タグの属性(初期値 : array()) |
$escape | boolean | エスケープ有無(初期値 : false) |
return | string | $text 変換後文字列 |
public function mark($search, $text, $name = 'strong', $attributes = array(), $escape = false)
{
if (!is_array($search)) {
$search = array($search);
}
$options = array('escape' => $escape);
if (!empty($attributes)) {
$options = array_merge($options, $attributes);
}
foreach ($search as $value) {
$text = str_replace($value, $this->BcHtml->tag($name, $value, $options), $text);
}
return $text;
}