小编car*_*mba的帖子

通过字符串中最后一次出现的字符串来爆炸字符串返回第一个和最后一个部分

更新:$ string可以有一个或多个";".我必须照顾最后一个.

$string = "Hello world; This is a nice day; after";

$out[] = trim( substr( strrchr ($string, ";"), 1 ) );
$out[] = trim( substr( strrchr ($string, ";"), 0 ) );

var_dump($out);
Run Code Online (Sandbox Code Playgroud)

结果:array(2){[0] => string(3)"在"[1] => string(5)"后面;"}之后

但我需要的是:

array(2){[0] => string(3)"在"[1] => string(5)之后"Hello world;这是美好的一天"}

我该怎么办?

php

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

PHP将数据附加到数组对象

在PHP中我有一个数组$test.运行var_dump($test)看起来像这样:

array(2) {
  [0]=>
  object(stdClass)#2 (6) {
    ["name"]=>
    string(45) "Lorem"
    ["title"]=>
    string(96) "Lorem ipsum"
  }
  [1]=>
  object(stdClass)#3 (6) {
    ["name"]=>
    string(41) "Ipsum"
    ["title"]=>
    string(86) "Dolor sit amet"
  }
}
Run Code Online (Sandbox Code Playgroud)

现在我需要向对象添加另一个field(url),$test如下所示:

array(2) {
  [0]=>
  object(stdClass)#2 (6) {
    ["name"]=>
    string(45) "Lorem"
    ["title"]=>
    string(96) "Lorem ipsum"
    ["url"]=>
    string(86) "http://www.google.com"
  }
  [1]=>
  object(stdClass)#3 (6) {
    ["name"]=>
    string(41) "Ipsum"
    ["title"]=>
    string(86) "Dolor sit amet"
    ["url"]=>
    string(86) "http://www.stackoverflow.com"
  }
}
Run Code Online (Sandbox Code Playgroud)

我试过foreach()$test->append('xxxxxxxx');,但我得到的错误.这真的不容易吗?我究竟做错了什么?

php arrays object

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

在css中显示和隐藏div行

<style>
#table{
    display:table;
}   
#table div.row{
    display:table-row;
}
#table div.row div{
    display:table-cell;
    width:100px;
    text-align:right;
}
#table div.row:first-child{
    color:white;
    background-color:blue;
}
#table div.row:last-child{
    color:white;
    background-color:green;
}

#table div.row:last-child{
    display:none;
}
#table div.row:hover{
    display:table-row;
}
</style>

<div id='table'>
    <div class='row'>
        <div>CELL</div><div>CELL</div><div>CELL</div>
    </div>
    <div class='row'>
        <div>CELL</div><div>CELL</div><div>CELL</div>
    </div>  
</div>
Run Code Online (Sandbox Code Playgroud)

我不能摆脱我的任务,在那里,我们将制作一个2行的表,在默认视图中只有一行,因为最后一行是隐藏的(显示:无),然后当你将鼠标悬停在表格第二行会出现,我不知道我的CSS有什么错误?你觉得这行CSS是我错误的来源吗#table div.row:hover {display:table-row;},谢谢你的到来.

这是我的小提琴

html css

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

如何为html或css中的文本创建自定义下划线或突出显示?

我试图弄清楚如何为文本创建自定义背景效果。换句话说,我该如何做这样的事情: 在此处输入图片说明

html css text underline

0
推荐指数
2
解决办法
2527
查看次数

标签 统计

css ×2

html ×2

php ×2

arrays ×1

object ×1

text ×1

underline ×1