Home  >  Article  >  Backend Development  >  MYSQL中的一个有关问题

MYSQL中的一个有关问题

WBOY
WBOYOriginal
2016-06-13 13:34:52854browse

MYSQL中的一个问题

PHP code


数据库中字段title这一列:

羽毛球YMQ
橄榄球GLQ
曲棍球QGQ


改成:

羽 毛 球 YMQ
橄 榄 球 GLQ
曲 棍 球 QGQ




应该怎么写呢?

------解决方案--------------------
PHP code

$a='羽毛球YMQ';



$b=preg_replace('/[A-Za-z](.*)/i','',$a);


$b1=str_split($b,2);

$b2=implode(" ", $b1);


$c=preg_replace("//m.sbmmt.com/m/".$b."//m.sbmmt.com/m/",'',$a);

//echo $c;

$result=$b2." ".$c;

echo $result;

------解决方案--------------------
GBK 编码的?

mysql_select_db("new");
mysql_query("set names 'gbk'");//只要这一句

$a='羽毛球YMQ';
echo preg_replace('/[\x80-\xff]./', '$0 ', $a);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]