我正用头撞在我的桌子上,试图弄清楚为什么这个 PHP 代码会导致这个错误:Undefined index: arr. 我正在使用 Laravel,这段代码在外面就像黄金一样工作,但在 Laravel 内部,它返回了未定义的索引错误。
这是代码:
function set_pilots_array($line_array)
{
$airports = $this->airports;
$pilots = $this->pilots;
foreach($airports as $airport)
{
if($airport == $line_array[11] || $airport == $line_array[13])
{
if($airport == $line_array[11])
{
$deparr = "dep";
}
if($airport == $line_array[13])
{
$deparr = "arr";
}
$this->pilots[$deparr][] = array($line_array[0], $line_array[11], $line_array[13], $line_array[7], $line_array[5], $line_array[6], $line_array[8]);
}
}
}
function get_pilots_count()
{
$count = count($this->pilots['dep']) + count($this->pilots['arr']);
return $count;
}
Run Code Online (Sandbox Code Playgroud)
这种类型与我的另一个问题相吻合:Grab and Explode Data 它使用以下代码从数据文件中提取数据: …
我正在使用Twitter Boostrap重新设计网站,我需要一些jQuery帮助.我正在使用与引导程序打包在一起的'Popover'附加组件,我将它放在#div标记中(#onlinedata是特定的),并且我使用jquery每10秒重新加载一次div.这很好,但是,如果你碰巧悬停在div刷新时激活popover的链接,那么popover就会卡住.
我正在使用此代码进行刷新:
setInterval(function(){
$("#onlinedata").load("http://website.com #onlinedata");
}, 10000);
Run Code Online (Sandbox Code Playgroud)
如果需要,激活popover的代码:
$(function () {
$('a[rel=popover]').popover({
placement:'right',
title:'Title',
content: $('#div-that-contains-data').html()
});
});
Run Code Online (Sandbox Code Playgroud)
当div重新加载时,有没有办法避免弹出窗口被卡住?
任何帮助是极大的赞赏.
相关的HTML
这$id是每个弹出窗口的特定键,因为我有多个弹出窗口.
在popover_controller悬停之前隐藏的弹出部分:
<div id="controller_popup_$id" style="display:none;">
<div style="font-size:11px">
//data_fetched_from_database
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
触发弹出窗口的链接
<li><a href="#" rel="popover_controller_$id">Link Title</a></li>
Run Code Online (Sandbox Code Playgroud)
最后,我正在使用的当前javascript(它通过数据库记录循环,因此每条记录获取以下javascript):
$(function () {
$('a[rel=popover_controller_$id]').popover({
placement:'right',
title:'Title (this is fetched from the database for each popover)',
content: $('#controller_popup_$id).html()
});
});
$(document).ready(function() {
// refreshing code
setInterval(function() {
$('#controller_popup_$id').hide(); // close any open popovers
// fetch new html
$('#onlinedata').load('http://website-link.com #onlinedata', …Run Code Online (Sandbox Code Playgroud) 我需要一些帮助来反序列化和更新数组值并重新序列化它们(使用php).基本上我希望能够反序列化字符串,更新特定键的值(不丢失其他值)并重新序列化它.我已经搜索过,似乎无法找到可行的解决方案(或者我可能只是一种性格问题).
我正在尝试更新的数组非常简单.它具有关键和价值.
array (
'key' => 'value',
'key2' => 'value2',
)
Run Code Online (Sandbox Code Playgroud)
我目前有,但它不起作用.
foreach(unserialize($serializedData) as $key => $val)
{
if($key == 'key')
{
$serializedData[$key] = 'newValue';
}
}
$updated_status = serialize($serializedData);
Run Code Online (Sandbox Code Playgroud)