回答編集履歴
2
PruneMazuiさんのアドバイスより、mb_striposをstriposに修正
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
foreach($array as $value){
|
24
24
|
|
25
|
-
if(
|
25
|
+
if(stripos($value['name'],$match_keyword) !== false){
|
26
26
|
|
27
27
|
$keyword_count++;
|
28
28
|
|
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
- 配列のループ処理はforeachで代用できるため、これに変更しました。
|
46
46
|
|
47
|
-
- stristr()を
|
47
|
+
- stristr()をstripos()に変更しました。
|
48
48
|
|
49
49
|
|
50
50
|
|
@@ -59,13 +59,3 @@
|
|
59
59
|
|
60
60
|
|
61
61
|
公式ドキュメントの記述はこれのみですが、同じ理由で[stristr()](http://php.net/manual/ja/function.stristr.php)よりも[stripos()](http://php.net/manual/ja/function.stripos.php)が適していると考えました。
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
また、検索文字列「PHP」が、実運用で日本語などのマルチバイト文字を含む場合、[マルチバイト文字列関数](http://php.net/manual/ja/ref.mbstring.php)がより適しています。
|
66
|
-
|
67
|
-
このため、[stripos()](http://php.net/manual/ja/function.stripos.php)のマルチバイト文字列関数である[mb_stripos()](http://php.net/manual/ja/function.mb-stripos.php)にしています。
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
なお、PHPを実行している文字コードは`UTF-8`としています。
|
1
「なお、」を追加
test
CHANGED
@@ -68,4 +68,4 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
PHPを実行している文字コードは`UTF-8`としています。
|
71
|
+
なお、PHPを実行している文字コードは`UTF-8`としています。
|