LoginSignup
9
8

More than 5 years have passed since last update.

配列の中身を取り出しながらmb_convert_encodingすると遅いので、なんとかするー

Last updated at Posted at 2015-11-20

配列の中身を取り出しながらmb_convert_encodingする

よくやりますよね?

sample1
$outs = array('てすと','ほげほげ','ごほごほ');
foreach ($outs as $out) {
 $out_utf8 = mb_convert_encoding($out, "UTF-8", "SJIS");
 hoge-
}

とか。しかし、これは遅いんです。

関数一つで簡単に文字コードが変換出来ます!

sample2
$outs = array('てすと','ほげほげ','ごほごほ');

// 配列の文字コードを変換
mb_convert_variables('UTF-8' , 'SJIS' , $outs );

おしまい。楽ちんです。

参考URL:PHP/mb_convert_variables

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8