首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP漂亮的引号

PHP漂亮的引号
EN

Stack Overflow用户
提问于 2010-08-03 05:40:10
回答 2查看 395关注 0票数 1

让PHP将常规引号转换为漂亮引号的最好方法是什么?

即,转换为-

直接引号:

Poe's Great Aunt Sally said Poe said, "Once upon a midday dreary."

转换为卷曲的“漂亮的引号”:

Poe’s Great Aunt Sally said Poe said, “Once upon a midday dreary.”

EN

回答 2

Stack Overflow用户

发布于 2010-08-03 05:47:27

试试这个:

代码语言:javascript
复制
function convert_quotes($string) {
    $string = " " . $string . " "; //add spaces to beginning and end of string to catch strings that begin and/or end with quotes
    $search = array(" '", //use spaces to determine which direction a quote show curl.
                     "' ",
                     "'",
                     ' "',
                     '" '
    );
    $replace = array("‘",
                    "’",
                    "’",
                    "“", 
                    "”"
    );

    return trim(str_replace($search, $replace, $string)); //replace quotes and trim spaces added at beginning of function
}
票数 1
EN

Stack Overflow用户

发布于 2010-08-03 06:10:53

已经有一个名为"SmartyPants“的插件,最初是由John Gruber创建的,他因”大胆的火球“而出名。它最初是为MoveableType创建的

但其他人已经创建了可供您使用的PHP版本。看看这个:

http://michelf.com/projects/php-smartypants/

或者你可以在谷歌上搜索"SmartyPants PHP“,你会找到更多的选项。

同样为了参考,人们也将这些称为“智能引号”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3392009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档