“Nilai Kunci Array PHP” Kode Jawaban

PHP Keys of Array

$array = array(0 => 100, "cor" => "vermelho");
print_r(array_keys($array));

$array = array("azul", "vermelho", "verde", "azul", "azul");
print_r(array_keys($array, "azul"));

$array = array("cor"     => array("azul", "vermelho", "verde"),
               "tamanho" => array("pequeno", "medio", "grande"));
print_r(array_keys($array));
Fernando Gunther

Nilai Kunci Array PHP

<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
foreach($age as $x=>$x_value)
  {
  echo "Key=" . $x . ", Value=" . $x_value;
  echo "<br>";
  }
?>
Lonely Lemur

Tetapkan $ variabel array pasangan nilai kunci ke beberapa variabel php

$healthStructureData = [
            'product' => $product,
            'website_data' => $website_data,
            'total_keywords' => $total_keywords,
            'certificate_status' => $certificate_status,
            'total_user_websites' => $total_user_websites,
        ];

foreach ($healthStructureData as $key => $value) {
  $$key = $value;
}
Lokesh003Coding

PHP Return Associative Array

function myfunc(){
    $arr = array();
    $arr[] = 'value0';
    $arr['key1'] = 'value1';
    $arr['key2'] = 'value2';
    $arr[] = 'value3';
    return $arr;
}
Fancy Finch

php mengambil nilai kunci array 2 level

foreach($bigArray as $array){    
    foreach($array as $key=>$value){
        echo $key;
    }
}


#If if helps you give it Thumbs up
Relieved Rook

variabel php sebagai kunci dalam array

$id = 1;
$age = 2;    
$sort = "id"; // or "age";
    $Key = $$sort;
$arr = array($Key => 'string');

print_r($arr);
Defiant Dog

Jawaban yang mirip dengan “Nilai Kunci Array PHP”

Pertanyaan yang mirip dengan “Nilai Kunci Array PHP”

Lebih banyak jawaban terkait untuk “Nilai Kunci Array PHP” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya