Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

create associative array php by key value site:stackoverflow.com

    function array_group(array $data, $by_column) {
        $result = [];
        foreach ($data as $item) {
            $column = $item[$by_column];
            unset($item[$by_column]);
            if (isset($result[$column])) {
                $result[$column][] = $item;
            } else {
                $result[$column] = array($item);
            }
        }
        return $result;
    }

$result = array_group($assocArray,'name');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #associative #array #php #key
ADD COMMENT
Topic
Name
5+9 =