“PHP Obtenha chaves e valores da matriz” Respostas de código

Obtenha a chave do 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;
?>

Kaotik

PHP Obtenha chaves e valores da matriz

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
Lazurite

Respostas semelhantes a “PHP Obtenha chaves e valores da matriz”

Perguntas semelhantes a “PHP Obtenha chaves e valores da matriz”

Mais respostas relacionadas para “PHP Obtenha chaves e valores da matriz” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código