English 中文(简体)
数组中每个元素在填充后具有相同值( PHPP)
原标题:Every element in an array has the same value after filling (PHP)
  • 时间:2012-05-24 00:27:35
  •  标签:
  • php
  • arrays

我在为公司做一个订单处理 我遇到了一些问题

对于我们数据库中的每个顺序, 我将创建一个命令对象, 包含所有该顺序的信息( 例如: 命令 ID 、 客户地址等 ) 。 在此之后, 我将每个对象放入一个阵列, 最终传递到另一个页面, 进入该信息 。

现在,如果我对每个订单对象做一个 var_ dump, 我就会得到正确的值。 但是, 如果我对对象阵列做一个 var_ dump( 标注大小为 100 ), 我只能得到最后一个对象重复100 倍 。

因此:

    $order = new Order();
    $newOrder = array();

    ... While Loop to fill orders ...
    {

        ... Fill $order with data ...

        $newOrder[] = $order;
    }

如果我用Var_dump或打印_r $NewOrder, 我就会得到我输入的最后一份美元订单, n次。 如果我打印每份单子, 当我在循环中输入时, 它的输出正确 。

Thanks in advance! Any help would be greatly appreciated.

最佳回答

$order = new order () ; 应该在循环中。 已经修好了 。

谢谢你提格朗

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签