小编Sha*_*hdi的帖子

如何在PHP关联数组中存储键和值?

我有一个PHP代码

$brandNames = array();
foreach ($maufacturers as $manu) {
    array_push($brandNames, array($manu->getTitle() => $manu->getUrl()));
}
print_r($brandNames);
Run Code Online (Sandbox Code Playgroud)

我得到输出为

Array
(
    [0] => Array
        (
            [key0] => val0
        )

    [1] => Array
        (
            [key1] => val1
        )

    [2] => Array
        (
            [key2] => val2
        )
)
Run Code Online (Sandbox Code Playgroud)

我需要输出为

Array
(
     [key0] => val0
     [key1] => val1
     [key2] => val2
     [key3] => val3
)
Run Code Online (Sandbox Code Playgroud)

不是嵌套数组只是一个包装器数组中的所有键和值.

php associative-array

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

片段内容在导航抽屉中的ActionBar上重叠

为什么Fragment布局重叠ActionBar如此

  1. FirstFragment

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".FirstFragment">
    
    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/hello_first_fragment" />
    
    Run Code Online (Sandbox Code Playgroud)

    在此输入图像描述

  2. SecondFragment

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/hello_second_fragment" />
    
    Run Code Online (Sandbox Code Playgroud)

    在此输入图像描述

activity_navigation

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_navigation"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_navigation"
        app:menu="@menu/activity_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

app_bar_navigation

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.sup.slideup.Navigation">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-actionbar navigation-drawer

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

如何在Angular 6中构建具有多个组件的表单?

我正在尝试构建跨越多个组件的Reactive-Form,就像这样

<form [formGroup]="myForm" (ngSubmit)="onSubmitted()">
   <app-names></app-names>
   <app-address></app-address>
   <app-phones></app-phones>
   <button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)

当我尝试提交时,我得到空对象.

Stackblitz在这里

typescript angular angular-reactive-forms angular-forms angular6

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