preg_match("#(.{100}$keywords.{100})#", strip_tags($description), $matches);
Run Code Online (Sandbox Code Playgroud)
我试图在每一侧只显示100个字符,中间有搜索字符串.
这段代码实际上有效,但它区分大小写,我如何使其不区分大小写?
如下面的示例显示如何调用字段,我的问题是如何调用多重复选框.请举个例子
$merge_vars = array('FNAME'=>'Test', 'LNAME'=>'Account',
'GROUPINGS'=>array(
array('name'=>'Your Interests:', 'groups'=>'Bananas,Apples'),
array('id'=>22, 'groups'=>'Trains'),
)
);
Run Code Online (Sandbox Code Playgroud)
我得到了解决方案.
要获得多重复选复选框,您需要进行循环并将其设置为数组,然后将数组更改为字符串.
if(!empty($_POST['listbox']))
{
foreach($_POST['listbox'] as $value => $val)
{
$values[] = $val;
}
$groups = implode(",", $values);
}
Run Code Online (Sandbox Code Playgroud)
然后在merge_vars中设置它
$merge_vars = array('FNAME'=>'Test', 'LNAME'=>'Account',
'GROUPINGS'=>array(
array('name'=>'Your Interests:', 'groups'=> $groups)
)
);
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你 :)
当我试图在同一页面上发送价值时,我有点困惑.
<script>
$("select[name='sweets']").change(function () {
var str = "";
$("select[name='sweets'] option:selected").each(function () {
str += $(this).text() + " ";
});
jQuery.ajax({
type: "POST",
data: $("form#a").serialize(),
success: function(data){
jQuery(".res").html(data);
$('#test').text($(data).html());
}
});
var str = $("form").serialize();
$(".res").text(str);
});
</script>
<div id="test">
<?php
echo $_POST['sweets'];
?>
</div>
<form id="a" action="" method="post">
<select name="sweets" >
<option>Chocolate</option>
<option selected="selected">Candy</option>
<option>Taffy</option>
<option>Caramel</option>
<option>Fudge</option>
<option>Cookie</option>
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
好吧,如果它位于html标签的顶部,它将显示,但如果它在体内,它将显示null.