php - 如何创建阵列组

标签 php arrays

如何在数组中对值进行分组,例如,我想这样获取它

[1]=>array(
   ["type"] => 1
   ["amount"] => array(2500,200,5000,400)
)
[2]=>array(
   ["type"] => 2
   ["amount"] => array(4500,500,5000,400)
)

最佳答案

你可以使用下面的代码:-

$ps = array();
$ps[]=array("type" => 1,  "amount" => array(2500,200,5000,400));
$ps[]=array("type" => 2 ,  "amount" => array(4500,500,5000,400));

print_r($ps);

关于php - 如何创建阵列组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9781989/

相关文章:

c - 反转数组元素(按位)不起作用

c++ - 在 C++ 中初始化哈希表数组的正确语法是什么?

php - 如何进行 PHP StdClass 反射

PHP 得到一个月后的约会

php - PHP 中 open_basedir 的用途是什么,它是如何工作的?

php - 从mySQL表中获取信息

php - 在 WooCommerce 管理订单中的 "Refund"按钮旁边添加另一个按钮

c# - 在 C# 中查找字节数组

arrays - ColdFusion 8中是否有类似于ColdFusion 9中的ArrayFind的功能?

arrays - MIPS:将用户输入字符串与内存中的字符串数组进行比较