How do I write PHP code to manually create this array?
Array (
[0] => Array
(
[Id] => 2
[Fruit] => Apple
)
[1] => Array
(
[Id] => 5
[Fruit] => Orange
)
)
$arr = array();
$arr[] = array("Id" => 2, "Fruit" => "Apple");
$arr[] = array("Id" => 5, "Fruit" => "Orange");
$array =array(
array('Id'=>2, 'Fruit'=>'Apple'),
array('Id'=>5, 'Fruit'=>'Orange')
);
NB: array keys are case-sensitive.
$array = array();
$array[] = array(
'id'=>3,
'Fruit'=>'Orange'
);
$array[] = array(
'id'=>7,
'Fruit'=>'Banana'
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.