我做了一个功能,用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)
但是你明白所有字符串都没有空间,这不是我们想要的.
这是我有的一个数组示例:
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
我试图在提交时获取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)
我阅读了所有Wordpress WP rest api文档,但我没有找到如何限制我想要的评论数量.我试过 http://mywebsite.com/wp-json/posts/999/comments?filter[comments_per_page]=1