PHP array_keys() ফাংশন

উদাহরণ

একটি নতুন এরেই একটি দেয়, যা একটি এক্সেকিউটিভ একশন হিসাবে একটি এক্সেকিউটিভ একশন পার্সিং করে

<?php
$a=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander");
print_r(array_keys($a));
?>

Run Instance

পরিভাষা এবং ব্যবহার

The array_keys() function returns a new array containing all the key names of the array.

If the second parameter is provided, only the key names with the specified key value will be returned.

If strict If the parameter is specified as true, PHP will use an exact comparison (===) to strictly check the data type of the key value.

Syntax

array_keys(array,value,strict)
Parameters Description
array Required. Specifies an array.
value Optional. You can specify a key value, and only the key names corresponding to that key value will be returned.
strict

Optional. With value Parameters used together. Possible values:

  • true - Returns the key names with the specified key value. Type dependent, number 5 is different from string "5".
  • false - Default value. Does not depend on type, number 5 is the same as string "5".

Technical Details

Return Value: Returns a new array containing all the keys of the array.
PHP Version: 4+
Update Log: strict The parameter was added in PHP 5.0.

More Examples

Example 1

Use value parameter:

<?php
$a=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander");
print_r(array_keys($a,"Highlander"));
?>

Run Instance

Example 2

Use strict parameter (false):

<?php
$a=array(10,20,30,"10");
print_r(array_keys($a,"10",false));
?>

Run Instance

Example 3

Use strict parameter (true):

<?php
$a=array(10,20,30,"10");
print_r(array_keys($a,"10",true));
?>

Run Instance