原字符串1,2,3,4,5,6,
去掉最后一个字符”,”,最终结果为1,2,3,4,5,6
代码如下:
$str = "1,2,3,4,5,6,"; $newstr = substr($str,0,strlen($str)-1); echo $newstr; //echo 1,2,3,4,5,6
系统自带的函数即可实现这样的效果,两种方法:
//函数1 substr($str, 0, -1) //函数2 rtrim($str, ",")
no Pain no Gain no Gavin
原字符串1,2,3,4,5,6,
去掉最后一个字符”,”,最终结果为1,2,3,4,5,6
代码如下:
$str = "1,2,3,4,5,6,"; $newstr = substr($str,0,strlen($str)-1); echo $newstr; //echo 1,2,3,4,5,6
系统自带的函数即可实现这样的效果,两种方法:
//函数1 substr($str, 0, -1) //函数2 rtrim($str, ",")
先上图:

最近MBP硬盘空间不够了,强烈推荐工具DaisyDisk,非常简单易用,不花钱也可以用,只是稍微麻烦点儿,业界良心。
最靠谱的方式是通过JS监控popstate事件,然后进行相应的处理。核心代码如下:
if (window.history && window.history.pushState) {
//document.addEventListener('visibilitychange', function() {
// alert(document.visibilityState);
//}, false);
//window.on('popstate', function() {
// alert("我监听到了浏览器的popstate");
//});
//window.onpopstate = function(e) {
// console.log(e.state);
//
//};
$$(window).on('popstate', function() { // 返回按钮
var hashLocation = location.hash; // 获取或设置页面的标签值
console.log("popstate");
console.log("hashLocation:"+hashLocation);
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1];
console.log("hashName:"+hashLocation);
if (hashName !== '') {
var hash = window.location.hash; // 获取或设置页面的标签值
console.log("hash:"+hash);
if (hash === '') {
alert('再次点击返回按钮退出程序');
}
}
});
console.log("pushstate");
var url = window.location.href;
var timestamp = new Date().getTime();
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
window.history.pushState('forward', null, './#forward');
} else {
window.history.pushState('', "大糖医", url+"#"+timestamp); // 状态对象、标题(现在会被忽略),可选的URL地址。
}
}css实现文本两行或多行文本溢出显示省略号,这个方法不兼容ie。
<style>
.comment_inner{
width: 200px;
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
-webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
-webkit-line-clamp: 3; /** 显示的行数 **/
overflow: hidden; /** 隐藏超出的内容 **/
}
</style>word-break 属性规定自动换行的处理方法。normal(使用浏览器默认的换行规则。),break-all(允许在单词内换行。),keep-all(只能在半角空格或连字符处换行。)