php

Get values array by key name using array_column() PHP

You can get an array of values by key name from an associative array using the array_column() function PHP

<?php
    $employees = array(
        array(
            'emp_name' => 'Rick Grimes',
            'designation' => 'developer'
        ),
        array(
            'emp_name' => 'John Wick',
            'designation' => 'manager'
        )
    );

    $designations = array_column($employees, 'designation');
    print_r($designations);
?>
Was this helpful?