我有一个像这样的字符串:
$str = "it is a test";
Run Code Online (Sandbox Code Playgroud)
我想检查一下这些词:it,test.true如果字符串中至少有一个单词,我希望它返回.
这是我做的:( 虽然它不起作用)
$keywords = array ('it', 'test');
if(strpos($str, $keywords) !== false){ echo 'true';}
else echo 'false';
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我有一个像这样的字符串:
var str = "some text is here
- first case
- second case
- third case
some text is here";
Run Code Online (Sandbox Code Playgroud)
现在我需要这个输出:
var newstr = "some text is here
1. first case
2. second case
3. third case
some text is here";
Run Code Online (Sandbox Code Playgroud)
我所能做的就是删除那些-.现在我需要$1用动态数字替换......这可能吗?
像这样的东西:
.replace (/(^\s*-\s+)/gm, "{A dynamic number which is ascending}. ")
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的teatarea:
$("textarea").on('focus', function(){
alert("clicked");
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea col="3" row="20"></textarea>Run Code Online (Sandbox Code Playgroud)
正如你在上面提到的那样,每次当你专注于那个textarea时,alert()执行.如何限制它只执行一次?(刚刚第一次)
我有两个<div>这样的:
<div class='test' style='visibility: visible;'> div1 </div>
<div class='test'> div2 </div>
Run Code Online (Sandbox Code Playgroud)
现在我想在点击div1时向我显示警告,因为它有visibility属性.换句话说:
$(".test").click(function(e) {
if (this has visibility property){
alert('it has');
}
});
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何使用jquery在上面的代码中定义一个条件?
这是我的尝试:( 但没有一个不起作用)
if($(this).css('visibility').length != 0) {}
if($(this).css('visibility') == 'visible') {}
if($(this).hasClass('visibility-set')) {}
Run Code Online (Sandbox Code Playgroud)
那么,有什么解决方案吗?
我有一张这样的表:
// mytable
+----+---------+-------------------------------+
| id | title | content |
+----+---------+-------------------------------+
| 1 | hello | how are you? |
| 2 | you | it is content2 |
| 3 | what | hello is a word for greating |
| 4 | mouse | it is content4 |
+----+---------+-------------------------------+
Run Code Online (Sandbox Code Playgroud)
好吧,我想优先考虑title比content. 我的意思是,我想显示title列(第一个)的所有结果,然后显示content列(第二个)的所有结果。这里也是我的查询:
select * from mytable where match(title, content) against($word);
Run Code Online (Sandbox Code Playgroud)
这里还有两个例子:
示例 1:
$word = 'you';
Run Code Online (Sandbox Code Playgroud)
我想要这个输出:(专注于排序)
+----+---------+-------------------------------+
| id …Run Code Online (Sandbox Code Playgroud) 我有一个包含一些标签的字符串,就像这样;
$str = '<i>this</i> <u class="anything">is</u> a <b>string</b>';
Run Code Online (Sandbox Code Playgroud)
我要这个:
$newstr = 'this is a string';
Run Code Online (Sandbox Code Playgroud)
其实我想选择之间的一切<和>,然后用替换它''.我这样做的目标是防御CORS和CSRF漏洞.我怎样才能做到这一点?
我有一个名为的数组$arr = array.它的一些键有价值,如下所示:
$arr['1'] = 'one';
$arr['2'] = 'two';
$arr['3'] = 'three';
Run Code Online (Sandbox Code Playgroud)
现在我用另一个arry初始化该数组,有些事情是这样的:
$arr = array('4' => 'four', '5' => 'five');
Run Code Online (Sandbox Code Playgroud)
但我需要保留以前的值.我的意思是,当我打印该数组时,输出将如下所示:
echo '<pre>';
print_r($arr);
/* ---- output:
Array
(
[4] => four
[5] => five
)
*/
Run Code Online (Sandbox Code Playgroud)
虽然我想要这个输出:
Array
(
[1] => one
[2] => two
[3] => three
[4] => four
[5] => five
)
Run Code Online (Sandbox Code Playgroud)
那么,重新初始化后如何处理旧密钥(值)?
我有这样一个数组:
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches); // output is two number: 11, 12
Run Code Online (Sandbox Code Playgroud)
现在我想知道,如何将此数组传递$matches给此查询?
SELECT column_name(s)
FROM table_name
WHERE column_name IN ($matches); // actually I want something like this: IN (11, 12)
Run Code Online (Sandbox Code Playgroud)
有什么解决方案吗?