get key of value array php
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
get key of value array php
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
get array key php
array_keys ($array);
// It returns an array
// more informations at https://www.php.net/manual/fr/function.array-keys.php (fr)
php get keys and values from array
foreach($yourArray as $key => $value) {
echo '<a href="' . $value . '">' . $key . '</a>';
}
// OR
//Use functions
key($array); //Returns current key
reset($array); //Moves array pointer to first record
current($array); //Returns current value
next($array); //Moves array pointer to next record and returns its value
prev($array); //Moves array pointer to previous record and returns its value
end($array); //Moves array pointer to last record and returns its value
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us