如何通过某些键值对php数组进行分组

时间:2016-07-11 13:00:35

标签: php arrays

我得到一个看起来像这样的数组

from pyspark.sql import SQLContext
from pyspark import SparkContext

sc = SparkContext(appName="Connect Spark with Redshift")
sql_context = SQLContext(sc)
sc._jsc.hadoopConfiguration().set("fs.s3n.awsAccessKeyId", <ACCESSID>)
sc._jsc.hadoopConfiguration().set("fs.s3n.awsSecretAccessKey", <ACCESSKEY>)

df = sql_context.read \
    .option("url", "jdbc:redshift://example.coyf2i236wts.eu-central-    1.redshift.amazonaws.com:5439/agcdb?user=user&password=pwd") \
    .option("dbtable", "table_name") \
    .option("tempdir", "bucket") \
    .load()

但我想要的是像这样的东西

$(".compDiscSlider").each(function () {
        var val = $(this).next("input").val();
        $(this).slider({
            range: "min",
            animate: true,
            step: 0.25,
            min: 0.00,
            max: 100.00,
            value: val,
            slide: function (event, ui) {
                $(this).next("input").val(ui.value);
            }
        })
    });

1 个答案:

答案 0 :(得分:0)

我已经以保存密钥和所有内容的方式创建了它。让我知道它是否适合您:)

<?php
    $start = [
        ["cat" => "cat", "2" => 1],
        ["dog" => "dog", "3" => 1],
        ["cat" => "cat", "4" => 1]
    ];
    $end = [];

    foreach($start as $key => $array) {
        if(!isset($end[current($array)])) {
            $name = current($array);

            $end[$name][key($array)] = $name;
            next($array);
            $end[$name][key($array)] = current($array);
        } else {
            $name = current($array);

            next($array);
            $end[$name][key($array)] = current($array);
        }
    }

    $end = array_values($end);

    print_r($end);