如何在单列中获取多维数组

时间:2016-09-06 06:28:38

标签: php

这是我想要的单列中带有键的数组。

import android.app.Application;
import android.text.TextUtils;
import android.util.Log;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;



public class MyApplication extends Application{
    private RequestQueue mRequestQueue;
    private static MyApplication mInstance;
    public static final String TAG = MyApplication.class
            .getSimpleName();
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }
    public static synchronized MyApplication getInstance() {
        return mInstance;
    }
    public RequestQueue getReqQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }

        return mRequestQueue;
    }
    public <T> void addToReqQueue(Request<T> req, String tag) {
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        getReqQueue().add(req);
    }
    public <T> void addToReqQueue(Request<T> req) {
        req.setTag(TAG);
        getReqQueue().add(req);
    }
    public void cancelPendingReq(Object tag) {
        if (mRequestQueue != null) {
            mRequestQueue.cancelAll(tag);
        }
    }
}

我需要单列中的这个数组

    Array
(
    [0] => Array
        (
            [9] =>                  $2y$10$eP7dUFBqeCZItMg2A8cSFufAi7UC0OfKjzfpkohOAD/lHBsoM6tFu
        )

    [1] => Array
        (
            [76] => $2y$10$DZn/JI0.2HV6DHA9CfEWZ.9MoNNkIKozTURcA5vOTVUE8O8uaBF3.
        )

    [2] => Array
        (
            [7] => $2y$10$gSAtgpFVjhcMk2CAaLOuvOle3dkNqltZOu1I.0NzxOJT/COnu8evq
        )

    [3] => Array
        (
            [82] => $2y$10$B9vG6uBHY004Xn0s2TGkkuRJfuE1wlNqmuQno5ZWqjlwbObMohH5O
        )

我尝试压扁数组,但它没有在数组中显示0,1,2,3键。

2 个答案:

答案 0 :(得分:1)

$newArray有你想要的东西。

$newArray = array(); 
 foreach($arrayData as $valueArray){
   foreach($valueArray as $key=>$value){
    $newArray[$key]= $value;
  } 
}

答案 1 :(得分:1)

您也可以使用keycurrent对单个foreach执行相同的操作。

$res = [];
foreach($array as $v){
  $res[key($v)] = current($v); 
}