PHP - Get keys from array

Introduction

We can get a list of the keys of the array with array_keys, and a list of its values with array_values:

Demo

<?php
    $properties = [ //  w  w w  . jav a 2 s. c  om
        'firstname' => 'T', 
        'surname' => 'R', 
        'house' => 'S' 
    ]; 
    $keys = array_keys($properties); 
    var_dump($keys); 
    $values = array_values($properties); 
    var_dump($values); 
?>

Result

Related Topic