我已经在这一段时间里敲打了一会儿.
我有这个多维数组:
Array
(
[0] => Array
(
[0] => foo
[1] => bar
[2] => hello
)
[1] => Array
(
[0] => world
[1] => love
)
[2] => Array
(
[0] => stack
[1] => overflow
[2] => yep
[3] => man
)
Run Code Online (Sandbox Code Playgroud)
我需要得到这个:
Array
(
[0] => foo
[1] => bar
[2] => hello
[3] => world
[4] => love
[5] => stack
[6] => overflow
[7] => yep
[8] => man
)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我发现的所有其他解决方案都解决了具有不同键的多维数组.我的数组只使用简单的数字键.
我似乎无法解决这个问题.我想从RSS文件(http://feeds.bbci.co.uk/news/rss.xml)获取媒体:缩略图.
我做了一些研究,并尝试将来自/sf/ask/469512081/ 和其他来源的见解纳入其中 .
这就是我得到的:
$source_link = "http://feeds.bbci.co.uk/news/rss.xml";
$source_xml = simplexml_load_file($source_link);
$namespace = "http://search.yahoo.com/mrss/";
foreach ($source_xml->channel->item as $rss) {
$title = $rss->title;
$description = $rss->description;
$link = $rss->link;
$date_raw = $rss->pubDate;
$date = date("Y-m-j G:i:s", strtotime($date_raw));
$image = $rss->attributes($namespace);
print_r($image);
}
Run Code Online (Sandbox Code Playgroud)
当我运行脚本时,我看到的只是一个白页.如果我回显或print_r任何其他变量,那么它就像一个魅力.它只是造成问题的$ image.为什么这不起作用?感谢任何帮助!
我有以下段落:
<p>This is a first paragraph.</p>
<p>This is a second</p>
<p>A third paragraph is here.</p>
<p>And a fourth</p>
Run Code Online (Sandbox Code Playgroud)
第二段和第四段在句末没有句号.有没有办法选择这些段落然后用jquery/javascript删除它们?
我需要在每个句子开头的短划线之前删除所有单词.有些句子在破折号之前没有单词,而长句子中的破折号需要保留.这是一个例子:
如何更改这些字符串:
巴黎 - 总统尼古拉·萨科齐(Nicolas Sarkozy)从后面跑来重新选举......
加沙城 - 加沙和以色列之间的跨境战斗......
哥伦比亚卡鲁鲁 - 突然之间,亚马逊森林的无尽绿色......
地震和海啸袭击日本东北沿海一年后......
进入这些字符串:
总统尼古拉·萨科齐(Nicolas Sarkozy)从后面跑来重新选举......
加沙和以色列之间的跨界战斗......
突如其来,亚马逊森林的无尽绿色......
地震和海啸袭击日本东北沿海一年后......
如何使用javascript(或php,如果javascript不允许)完成此操作?
我有一个javascript数组:
var exclude = ["Santorum","Obama","Romney","Gingrich"];
Run Code Online (Sandbox Code Playgroud)
我有HTML链接:
<a href="" class="title">Santorum is seeking campaign funding</a>
<a href="" class="title">Clinton is stepping down as Secretary</a>
<a href="" class="title">Obama is seeking reelection</a>
Run Code Online (Sandbox Code Playgroud)
我想检查是否有任何a-links中有任何一个exclude-values,如果有,则删除它们.结果将是:
<a href="" class="title">Clinton is stepping down as Secretary</a>
Run Code Online (Sandbox Code Playgroud)
另外两个将被删除,因为它们拥有数组中的单词.我尝试过使用jQuery.inArray,但我似乎无法弄明白.谢谢你的帮助.
我想限制我所有 $("a.paragraph") 的字符串长度。我有以下代码:
var paragraph = $("a.paragraph").text();
var maxlength = 500;
var strlength = paragraph.length;
if (strlength > maxlength) {
var introduction = paragraph.substr(0,maxlength); // cut string
var search = introduction.lastIndexOf(" "); // find position of last space (last word cannot be cut)
introduction = introduction.substr(0, search); // cut string until last space
introduction = introduction + "..."; // add ... in the end
$("a.paragraph").text(introduction);
}
Run Code Online (Sandbox Code Playgroud)
此代码仅修改第一个元素并在所有段落上显示结果。如何循环每个段落?
我怎么转这个:
<a class="link">
<p class="paragraph">This is some text</p>
<p class="paragraph">This is some more text</p>
<p class="paragraph">And some more</p>
</a>
Run Code Online (Sandbox Code Playgroud)
进入这个:
<a class="link">
This is some text This is some more text And some more
</a>
Run Code Online (Sandbox Code Playgroud)
用jQuery.我尝试使用追加和合并,但我只是想不出来.
很抱歉问这个简单的问题,但我似乎没有找到任何答案.
如何检查字符串中是否有数字?
我试过了:
$string = "this is a simple string with a number 2432344";
if (preg_match('/[^0-9]/', "$string")) {
echo "yes a number";
} else {
echo "no number";
}
Run Code Online (Sandbox Code Playgroud)
似乎不起作用......
我正试图改变这个文字:
她说是时候找'解决方案了'
进入本文:
她说是时候找'解决'了
只使用Javascript.
我试过用:
str.replace(/'S /,"'s ");
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.
有任何想法吗?请注意,S之后的空格是一个重要的启发式方法.