teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

match

2016/05/01 12:28

投稿

takasima20
takasima20

スコア7468

answer CHANGED
@@ -3,6 +3,7 @@
3
3
  if (!function_exists('change2')) {
4
4
  function change2($mojiretu2_2) {
5
5
  preg_match_all("/(http|https):\/\/[-\w\.]+(:\d+)?(\/[^\s]*)?/", $mojiretu2_2, $pattarn2);
6
+ $replace2 = array();
6
7
  foreach ($pattarn2[0] as $key2=>$val2) {
7
8
  $replace2[] = "<a href='" . $val2 . "' target='_blank' style='font-size:0.9em;'>" . $val2 . "</a>";
8
9
  }
@@ -10,7 +11,8 @@
10
11
 
11
12
  $keyword_start = '>';
12
13
  $keyword_end = 'さん';
13
- preg_match_all("/'.preg_quote($keyword_start) . '.*' . preg_quote($keyword_end) . '/", $tmp, $match);
14
+ preg_match_all("/" . preg_quote($keyword_start) . '.*' . preg_quote($keyword_end) . "/", $tmp, $match);
15
+ $futoji = array();
14
16
  foreach ($match[0] as $key3=>$val3) {
15
17
  $futoji[] = "<span style='font-weight:bold;'>" . $val3 . "</span>";
16
18
  }

1

ret

2016/05/01 12:28

投稿

takasima20
takasima20

スコア7468

answer CHANGED
@@ -14,7 +14,7 @@
14
14
  foreach ($match[0] as $key3=>$val3) {
15
15
  $futoji[] = "<span style='font-weight:bold;'>" . $val3 . "</span>";
16
16
  }
17
- $ret = str_replace($match[0], $futoji, $mojiretu2_2);
17
+ $ret = str_replace($match[0], $futoji, $tmp);
18
18
 
19
19
  return $ret;
20
20
  }