Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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)
Comment

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
Comment

get key of array element php

$people = array(
  2 => array(
    'name' => 'John',
    'fav_color' => 'green'
  ),
  5=> array(
    'name' => 'Samuel',
    'fav_color' => 'blue'
  ));
$found_key = array_search('blue', array_column($people, 'fav_color'));
Comment

how to get array key in php


<?php
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

// this cycle echoes all associative array
// key where value equals "apple"
for($i = 0; $i< sizeof($array);$i++){
if (key($array[$i]) == 'apple') {
        echo key($array).'<br />';
    }
    //next($array);
}
?>

Comment

php get array key


<?php
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

// this cycle echoes all associative array
// key where value equals "apple"
while ($fruit_name = current($array)) {
    if ($fruit_name == 'apple') {
        echo key($array).'<br />';
    }
    next($array);
}
?>

Comment

get array key php

// The easiest way

var_dump(json_decode(json_encode($value), true));
Comment

PREVIOUS NEXT
Code Example
Php :: redirect wordpress core login 
Php :: base url in php 
Php :: php contains substring 
Php :: Obtener datos de usuario registrado en WordPress 
Php :: Creating a new laravelproject 
Php :: wp get category by id 
Php :: laravel make seeder 
Php :: how to add script in WordPress admin page 
Php :: malformed utf-8 characters possibly incorrectly encoded php 
Php :: php create zip from folder 
Php :: laravel token logout 
Php :: request get query string laravel 
Php :: php case switch 
Php :: laravel migrate seed 
Php :: laravel old request radio check 
Php :: serve in localhost using php 
Php :: symfony password generator command line 
Php :: php get current time and date 
Php :: laravel with has 
Php :: logout in php 
Php :: how to use wherein in json array laravel 
Php :: php sql get single value 
Php :: pass variable to another page in js 
Php :: php setinterval 
Php :: laravel pagination with get parameters 
Php :: multidimensional array item remove php 
Php :: how to change date formate in laravel 
Php :: codeigniter table list 
Php :: Flutter Error - Migrate to android studio - MAC OS 
Php :: phpspreadsheet read xlsx 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =