关联数组,ID为Key,其他关联数组为值? [英] Associative Array with ID as Key and other associative array as value?

查看:94
本文介绍了关联数组,ID为Key,其他关联数组为值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想创建一个带有PHP变量的关联数组(文章ID)

作为Key

和另一个关联数组,因为它的价值。


如何实现它,我该如何填充它?


我想要一些东西像这样:


$ articleTable = array($ articleNr => array(" name" => $ name," price" =>

$ price,amount=> 0);


(金额将在稍后的表格中填写。)


最后我想要一个包含来自

数据库的数据的数组,

这样的东西:


ArticleNr ArticleName价格金额

12345牙齿布鲁斯10 3

24939东西2 1

19492牙膏8 0

29491水1 4

那怎么办呢?


谢谢,


Stefan

解决方案

articleTable = array(

articleNr =>数组(" name" =>


name," price" =>


Hi,

I want to create an associative Array with a PHP variable (article ID)
as Key
and another associative array as it''s value.

How do I instanciate it, how can I fill it?

I want something like this:

$articleTable= array( $articleNr => array("name" => $name, "price " =>
$price ,"amount" => 0 );

( Amount will be filled later in a form.)

At the end I want an Array that contains data coming from the
database,
something like this:

ArticleNr ArticleName Price Amount
12345 tooth bruth 10 3
24939 stuff 2 1
19492 tooth paste 8 0
29491 water 1 4
So how can this be done?

Thanks,

Stefan

解决方案

articleTable= array(


articleNr => array("name" =>


name, "price " =>


这篇关于关联数组,ID为Key,其他关联数组为值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆