0

我想将值插入到数组的内部数组特定项中。

所以我有一个数组,它在函数之间丢失数据,我找不到应该在何时何地打印出一些值,但我可以从一个对象中获取这些值,我想将对象的项目注入到数组的内部数组 [value] 项。在对象中,我的名称与数组中的名称相同。

对象看起来像这样

Userinfos Object
(
    [address_type] => BT
    [address_type_name] => 
    [company] => 
    [title] => 
    [last_name] => Last Name
    [first_name] => First Name
    [middle_name] => 
    [phone_1] => 1234567
    [phone_2] => 
    [fax] => 
    [address_1] => Street address
    [address_2] => 
    [city] => City
    [virtuemart_state_id] => 0
    [virtuemart_country_id] => 97
    [zip] => 1234
    [agreed] => 0
    [created_on] => 0000-00-00 00:00:00
    [created_by] => 0
    [modified_on] => 2012-08-08 22:04:36
    [modified_by] => 853
    [email] => webmaster@universumpoker.com
    [username] => webmaster@universumpoker.com
)

数组看起来像这样

Array
(
    [email] => Array
        (
            [name] => email
            [value] => 
            [title] => E-Mail
            [type] => emailaddress
            [required] => 1
            [hidden] => 
            [formcode] => <input type="text" maxlength="100" class="required" value="" size="30" name="email" id="email_field"> 
        )

    [last_name] => Array
        (
            [name] => last_name
            [value] => 
            [title] => Last Name
            [type] => text
            [required] => 1
            [hidden] => 
            [formcode] => <input type="text" maxlength="32" class="required" value="" size="30" name="last_name" id="last_name_field"> 
        )

    [first_name] => Array
        (
            [name] => first_name
            [value] => 
            [title] => First Name
            [type] => text
            [required] => 1
            [hidden] => 
            [formcode] => <input type="text" maxlength="32" class="required" value="" size="30" name="first_name" id="first_name_field"> 
        )
)

正如您在此数组中看到的,[value] 为空,而在 [formcode] 中,输入的值也为空。

那么有没有办法将对象的值推送到数组中。我正在研究 array_push 但无法弄清楚目标 [value]

4

1 回答 1

0

你能不能像这样简单地设置值:

$array->first_name[$index]->value = $userinfos->first_name

围绕您的所有用户信息循环?

于 2012-08-08T22:54:04.260 回答