标签: explode

如何正确输入标签?

我的网页上有一个标记字段,用户可以在其中输入用,逗号分隔的标记,与在StackOverflow中完成相同.我正在使用PHP,我正在使用爆炸功能根据逗号分隔用户输入的所有标签,然后将它们添加到我的数据库中的标签表中.

我的代码是用于正常工作的标签完美的一样,如果用户输入battleship, strategy, sea war那么它的工作,但可以说,用户enetered battleship, strategy, sea war,或battleship, strategy, games, sea war, , , , ,或battleship, strategy, games,, sea war或任何错误的值,那么我将如何检测,然后输入唯一正确的价值罪数据库.

是否可以使用regExp或任何其他方式,请告诉我如何?

php tagging explode

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

在Internet Explorer中jQuery UI爆炸的奇怪行为

我试图在用户点击一个框后显示背景图像.(我知道我对CSS有点懒惰)

<script type="text/javascript">
$(document).ready(function() {
        var options = {};
        $(".toggler1").click(function() {
            $("#effect1").effect("explode",options,1000);
            $(".toggler1").html("<div id='effect1b' style='float:left;width:207px;height:153px;></div>");
            return false;
        });
});
</script>
Run Code Online (Sandbox Code Playgroud)

图像容器是

<div class="toggler1">
    <div id="effect1" style="float:left;width:207px;height:153px;border:none;">
        <p>
        </p>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

样式表很简单

<style type="text/css">
    #effect1b {
    background: url("2_01.jpg");
    }   
</style>
Run Code Online (Sandbox Code Playgroud)

为什么这会在Firefox中运行而在IE中不起作用?我想我有点疯了!

jquery internet-explorer jquery-ui explode

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

由换行符分隔的文件中最常出现的单词的数组.

如何从由换行符分隔的文件中获取最常出现的单词数组(\n)?

示例文件:

person
person
dog
cat
person
lemon
orange
person
cat
dog
dog
Run Code Online (Sandbox Code Playgroud)

文件中的单词没有特定的顺序.

我怎么能让它表现得如下?

echo $ top [0]; //输出:person
echo $ top [1]; //输出:狗
等......

提前致谢!

php arrays string explode

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

PHP preg_split无论如何要保持分割字符串?

如果我有以下字符串

$string = "
0001

a
b
c
d
e

0002

f
g
h
i
j
";
Run Code Online (Sandbox Code Playgroud)

我正在分裂它,$r = preg_split("/\d{4}\n/", $string);并且工作正常,但我也想包括分隔字符串..

就是在这一刻,这给了我

Array [0] {

a
b
c
d
e
}

 => [1] {

f
g
h
i
j
}
Run Code Online (Sandbox Code Playgroud)

但我希望它包括分隔符即

Array [0] {
0001

a
b
c
d
e
}

 => [1] {
0002

f
g
h
i
j
}
Run Code Online (Sandbox Code Playgroud)

希望有意义..

谢谢

背风处

php arrays explode preg-match preg-split

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

Double爆炸数组

字符串:

user:hello,user2:world
Run Code Online (Sandbox Code Playgroud)

期望的输出:

$string = array(
   1 => array( 1 => "user", 2 => "hello"),
   2 => array( 1 => "user2", 2 => "world")
);
Run Code Online (Sandbox Code Playgroud)

我尝试过的(不起作用):

$string = explode(',',$string);
$string = explode(':',$string);
Run Code Online (Sandbox Code Playgroud)

我得到的错误:explode() expects parameter 2 to be string
如何从字符串到所需的输出?谢谢!

php arrays explode

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

非破坏性的爆炸

爆炸一个字符串是破坏性的,因为你爆炸的字符串被破坏了.

$str = "ABCDEFGHIJKABCDEFGHIJK";
$arr = explode("DE",$str);
Run Code Online (Sandbox Code Playgroud)

$ arr现在是:

[0] = ABC
[1] = FGHIJKABC
[2] = FGHIJK
Run Code Online (Sandbox Code Playgroud)

是否有类似的(和有效的)方法用"DE"爆炸相同的字符串,但结束时:

[0] = ABC
[1] = DEFGHIJKABC
[2] = DEFGHIJK
Run Code Online (Sandbox Code Playgroud)

唯一的另一个参数explode是对返回多少件的限制.

php arrays explode

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

爆炸PHP字符串

我需要一些帮助,是否有可能像这样爆炸?我有一个字符串45-test-sample,是否有可能

[0]=>string == "45"
[1]=>string == "test-sample" 
Run Code Online (Sandbox Code Playgroud)

怎么做到呢?

php explode

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

仅从php中的一行提取字符串

我使用explode只从整行中提取字符串.但是使用这个:

$array = explode(" ", $line);
Run Code Online (Sandbox Code Playgroud)

它只将一行空格分开,而不是单词.例如,如果$ line是

$line="word1  word2    word3"
Run Code Online (Sandbox Code Playgroud)

然后我在数组中的条目之间也有空格(它包含:"word1","word2"和"word3",但也包含一个或两个"").

有谁知道如何只获得数组中的三个条目"word1","word2"和"word3"?

php string explode

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

PHP爆炸大写单词

我如何在PHP大写单词中爆炸?喜欢:

$text = "HELLO world FROM BRAZIL";
$up = explode(' ',$text);
($up[0] = HELLO, $up[1] = world, $up[2] = FROM BRAZIL)
Run Code Online (Sandbox Code Playgroud)

谢谢

php words explode uppercase

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

将foreach分解为新数组

我有JSON API响应,看起来像这样

Array
(
    [sections] => Array
        (
            [0] => Array
                (
                    [id] => 115000089967
                    [url] => xxxxx
                    [html_url] => ArticleHTML1
                    [category_id] => 204458828
                    [position] => 0
                    [sorting] => manual
                    [created_at] => 2016-12-19T14:56:23Z
                    [updated_at] => 2017-02-03T08:23:04Z
                    [name] => ArticleName1
                    [description] => 
                    [outdated] => 
                )

            [1] => Array
                (
                    [id] => 207077828
                    [url] => xxxxxx
                    [html_url] => ArticleHTML2
                    [category_id] => 204458828
                    [position] => 1
                    [sorting] => manual
                    [created_at] => 2016-11-14T09:28:30Z
                    [updated_at] => 2017-02-02T09:15:42Z
                    [name] => ArticleName2
                    [description] => 
                    [outdated] => 
                ) …
Run Code Online (Sandbox Code Playgroud)

php arrays json explode

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