小编d.b*_*kov的帖子

在php中使用json_encode时删除数组索引引用

我使用jQuery创建了一个小应用程序datepicker.我从json文件设置不可用的日期,如下所示:

{ "dates": ["2013-12-11", "2013-12-10", "2013-12-07", "2013-12-04"] }
Run Code Online (Sandbox Code Playgroud)

我想检查一下给定的日期是否已经在此列表中,如果是,则将其删除.我当前的代码如下所示:

if (isset($_GET['date'])) //the date given
{
    if ($_GET['roomType'] == 2)
    {
        $myFile = "bookedDates2.json";
        $date = $_GET['date'];
        if (file_exists($myFile))
        {
            $arr = json_decode(file_get_contents($myFile), true);
            if (!in_array($date, $arr['dates']))
            {
                $arr['dates'][] = $_GET['date']; //adds the date into the file if it is not there already
            }
            else
            {
                foreach ($arr['dates'] as $key => $value)
                {
                    if (in_array($date, $arr['dates']))
                    {
                        unset($arr['dates'][$key]);
                        array_values($arr['dates']);
                    }
                }
            }
        }

        $arr = json_encode($arr);
        file_put_contents($myFile, $arr);
    } …
Run Code Online (Sandbox Code Playgroud)

php jquery json

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

Laravel 5.1-页面标题中的图标

我正在努力在页面标题中添加一个图标。到目前为止,我已经尝试过像这样添加它:

<title> <link rel="icon" href="{!! asset('images/gcm_ico.ico') !!}"/>@yield('page-title') </title>

但它在所有浏览器中都已逸出,如下所示:

在此处输入图片说明

我也尝试打印链接

{{ "<link rel='icon' hrer='".asset("images/gcm_ico.ico")."' />" }}.
Run Code Online (Sandbox Code Playgroud)

有人成功做到了吗?提前致谢

php page-title laravel blade laravel-5

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

标签 统计

php ×2

blade ×1

jquery ×1

json ×1

laravel ×1

laravel-5 ×1

page-title ×1