小编Gin*_*ino的帖子

PHP删除换行符或CR LF没有成功

我做了一个功能,用PHP删除换行没有成功,我尝试了所有替换代码,我仍然得到这些换行,我创建一个json文件,我无法从jsonp与jquery读取它因为这些换行似乎打破一切.

function clean($text)
{
$text = trim( preg_replace( '/\s+/', ' ', $text ) );  
$text = preg_replace("/(\r\n|\n|\r|\t)/i", '', $text);
return $text;
}
Run Code Online (Sandbox Code Playgroud)

当我查看源代码时,在所有href,img和br中都会出现一些换行符,这是一个json_encode输出示例:

<a
href=\"http:\/\/example.com\/out\/content\/\" title=\"link to content website\">
Run Code Online (Sandbox Code Playgroud)

换行a.img src和br是hapenig

我可以删除这些的唯一方法打破它

$text = preg_replace("/\s/i", '', $text);
Run Code Online (Sandbox Code Playgroud)

但是你明白所有字符串都没有空间,这不是我们想要的.

php line-breaks preg-replace

12
推荐指数
2
解决办法
4万
查看次数

修改和操作 JavaScript 数组

这是我有的一个数组示例:

var array= ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
Run Code Online (Sandbox Code Playgroud)

我想要这个结果:

['business', 'management', 'News', 'Entertainment News', 'Entrepreneurship']
Run Code Online (Sandbox Code Playgroud)

这意味着,与此 '>' 分开没有重复

这是我所在位置的一个示例,但它只是删除了箭头 '>' jsfiddle

javascript arrays

7
推荐指数
1
解决办法
132
查看次数

Twitter Boostrap - 获取popover textarea和输入值

我试图在提交时获取Bootstrap popover中的输入值,但我得到一个空值.

<div class="popover-markup"> <a href="#" class="trigger">Popover link</a> 
    <div class="head hide">Lorem Ipsum</div>
    <div class="content hide">
        <div class="form-group">
            <input type="text" id="myinput" class="form-control" placeholder="Type something…">
        </div>
        <button type="submit" id="mysubmit" class="btn btn-default btn-block">Submit</button>
    </div>
    <div class="footer hide">test</div>
</div>

$('.popover-markup>.trigger').popover({
    html: true,
    title: 'Get value',
    content: function () {
        return $(this).parent().find('.content').html();
    }
});

$(document).on("click", "#mysubmit", function () {
    var inputval = $("#myinput").val();
    alert(inputval);
    return false;
});
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/onigetoc/RvLrA/

jquery twitter-bootstrap twitter-bootstrap-3

5
推荐指数
1
解决办法
4905
查看次数

WP rest api:如何获得评论数量

我阅读了所有Wordpress WP rest api文档,但我没有找到如何限制我想要的评论数量.我试过 http://mywebsite.com/wp-json/posts/999/comments?filter[comments_per_page]=1

wordpress json

5
推荐指数
1
解决办法
1888
查看次数