Answers for "how to pass keys and value to array php"

PHP
8

push key value array php

$a = array("key1"=>"value1", "key2"=>"value2");

// to append "key3" - "value3":
$a["key3"] = "value3"
Posted by: Guest on August-23-2021
0

php variables as keys in arrays

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

print_r($arr);
Posted by: Guest on August-13-2020

Code answers related to "how to pass keys and value to array php"

Browse Popular Code Answers by Language