📜  在一些单词后显示点点 php 代码示例

📅  最后修改于: 2022-03-11 14:53:47.606000             🧑  作者: Mango

代码示例1
The PHP way of doing this is simple:

$out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;
But you can achieve a much nicer effect with this CSS:

.ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
Now, assuming the element has a fixed width, the browser will automatically break off and add the ... for you.