我正在寻找一个解决方案来放置一个div(100%的屏幕宽度,让我们说20%的高度)在iframe的顶部,这是100%的屏幕宽度和100%的屏幕高度它应该是这样的:
__________________________
|| On top DIV ||
||_______________________||
| |
| Iframe |
| |
|_________________________|
Run Code Online (Sandbox Code Playgroud) 我有preg_match_all函数:
preg_match_all('#<h2>(.*?)</h2>#is', $source, $output, PREG_SET_ORDER);
Run Code Online (Sandbox Code Playgroud)
它按预期工作,但问题是,它preg_matches所有项目两次,并进入一个巨大的多维数组,例如,如预期的那样,preg_matched所有11项所需,但两次,并进入一个多维数组:
Array
(
[0] => Array
(
[0] => <h2>10. <em>Cruel</em> by St. Vincent</h2>
[1] => 10. <em>Cruel</em> by St. Vincent
)
[1] => Array
(
[0] => <h2>9. <em>Robot Rock</em> by Daft Punk</h2>
[1] => 9. <em>Robot Rock</em> by Daft Punk
)
[2] => Array
(
[0] => <h2>8. <em>Seven Nation Army</em> by the White Stripes</h2>
[1] => 8. <em>Seven Nation Army</em> by the White Stripes
)
[3] => Array
(
[0] => <h2>7. …Run Code Online (Sandbox Code Playgroud) 我可以像这样在字符串中突出显示一个单词:
$str = "my bird is funny";
$keyword = "fun";
$str = preg_replace("/($keyword)/i","<b>$0</b>",$str);
Run Code Online (Sandbox Code Playgroud)
蚂蚁这会给我:我的鸟是乐趣纽约
但是,当关键字来自多个单词时,如何使这个工作起作用
$keyword = "bird fun";
Run Code Online (Sandbox Code Playgroud)
我想得到这样的结果:我的鸟是乐趣南阳
我有一个包含四列的MySQL表submited_name, submited_URL, submited_type, uniqueID.在这张表中我有大约1000条记录.我需要选择10个随机条目.问题是我需要将选定的随机值拆分为单独的PHP数组.每列一个.我的数组看起来像这样:
$ten_random_names = array ('name26', 'name55', 'name107', ect.);
$ten_random_URL = array ('url for name26', 'url for name55', 'url for name107', ect..);
$ten_random_types = array ('type for name26', 'type for name55', 'type for name107', ect..);
Run Code Online (Sandbox Code Playgroud) 可以说我有一堆坏话:
$badwords = array("one", "two", "three");
Run Code Online (Sandbox Code Playgroud)
随机字符串:
$string = "some variable text";
Run Code Online (Sandbox Code Playgroud)
如何创建此循环:
if (one or more items from the $badwords array is found in $string)
echo "sorry bad word found";
else
echo "string contains no bad words";
Run Code Online (Sandbox Code Playgroud)
示例:
如果$string = "one fine day" or "one fine day two of us did something",用户应该看到抱歉坏词找到的消息.
如果$string = "fine day",用户应该看到字符串包含没有坏词的消息.
据我所知,你不能preg_match从数组.有什么建议吗?
我有以下代码使用谷歌图片搜索API:
google.load('search', '1');
function searchComplete(searcher) {
// Check that we got results
if (searcher.results && searcher.results.length > 0) {
// Grab our content div, clear it.
var contentDiv = document.getElementById('contentimg');
contentDiv.innerHTML = '';
// Loop through our results, printing them to the page.
var results = searcher.results;
for (var i = 1; i < results.length; i++) {
// For each result write it's title and image to the screen
var result = results[i];
var imgContainer = document.createElement('div');
var newImg = …Run Code Online (Sandbox Code Playgroud) 如何转换带有非拉丁字符的字符串,如下所示:
\n\n\xe4\xbc\x8a\xe8\x97\xa4\xe3\x82\x8a\xe3\x81\xaa\nRun Code Online (Sandbox Code Playgroud)\n\n对此:
\n\n%E4%BC%8A%E8%97%A4%E3%82%8A%E3%81%AA\nRun Code Online (Sandbox Code Playgroud)\n\n在 PHP 中。谢谢 ;)
\nphp ×5
algorithm ×1
arrays ×1
css ×1
encode ×1
for-loop ×1
html ×1
iframe ×1
javascript ×1
mysql ×1
pcre ×1
preg-match ×1
preg-replace ×1
regex ×1
utf-8 ×1