Search
 
SCRIPT & CODE EXAMPLE
 

PHP

array key value php

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

php variables as keys in arrays

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

print_r($arr);
Comment

PREVIOUS NEXT
Code Example
Php :: laravel framework 
Php :: route laravel 
Php :: swift mailer 530 Must issue a STARTTLS command first. 
Php :: undefined variable inside function php 
Php :: find largest element of an array in php 
Php :: how to hide .php in url 
Php :: how to create a tryit editor 
Php :: how to implement email verification in laravel 
Php :: ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first! Considering conflict mpm_worker for mpm_prefork: ERROR: Could not enable dependency mpm_prefork for php7.2, aborting 
Php :: upgrade php 5.6 to 7 centos 7 
Php :: my xampp 
Php :: php abstract class static method 
Php :: add taxonomy to custom post type 
Php :: unexpected end of file php 
Php :: php class comment 
Php :: declare variable in view for loop laravel 
Java :: jlabel text center 
Java :: android glide dependency 
Java :: spigot cancel repeating task 
Java :: java log base 2 
Java :: android open browser 
Java :: how to make javafx full screen default 
Java :: How to solve the towers of Hanoi Java? 
Java :: generate random letters and numbers in java 
Java :: keyset sort java 
Java :: how to set scroll to bottom jscrollpane 
Java :: hibernate dependency 
Java :: java remove file extension from file name 
Java :: remove last character from string java 
Java :: android manifest internet permission 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =