數據相關函數
implode(separator,array)
<?php $arr = array('Hello','World!'); echo implode(" ",$arr); ?>
explode(separator,string,limit)
<?php $str = "Hello world!"; print_r (explode(" ",$str)); ?>
$str = iconv('UTF-8', 'GB2312', unescape(isset($_GET['str'])? $_GET['str']:'')); 報錯:iconv() : Detected an illegal character in input string //TRANSLIT 會自動將不能直接轉化的字元變成一個或多個近似的字元, //IGNORE 會忽略掉不能轉化的字元,而預設效果是從第一個非法字元截斷。 $str = iconv('UTF-8', 'GBK//IGNORE', unescape(isset($_GET['str'])? $_GET['str']:''));
替代方案
$content = iconv("GBK", "UTF-8", $content); $content = mb_convert_encoding($content, "UTF-8", "GBK");