Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to get keys of associative array php

/*
|===============================================================
| How to get keys of associative array php
|===============================================================
*/

//------ Method-1 -------
$countries = ["Pakistan" => "+92", "India" => "+91", "Qatar" => "+974"];
$country_codes = (array_keys($countires));

dd($country_codes);

//------ Method-2 -------
$countries = ["Pakistan" => "+92", "India" => "+91", "Qatar" => "+974"];
$country_codes = collect($countires)->keys();

dd($country_codes);
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #keys #associative #array #php
ADD COMMENT
Topic
Name
7+3 =