davedpss
-
Posts
9 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by davedpss
-
-
@justsomeguy, Thanks, that worked. I am curious as to why if I used the value of $key in stead of the variable e.g. $profile->field_first_name[0]['value'] = $value; that this worked. I would have thought that the arrays were created when I loaded the $profile object (earlier in the script). I have a similar script where I reference all the object properties by name instead of using a variable as part of the name and they all work??? Oh well, this fixes the issue. Thanks very much. Dave.
-
$profile is an object and I need to update properties of that object and then use node_save($profile) function to update the database. The issue is that the property names all have [0]['value'] in them. For example the $key variable might be "field_first_name" and the property to update is "field_first_name[0]['value']". I'm just having trouble trying to figure how to combine the value of $key with the string "[0]['value']" to create the property name. Thanks.
-
This is on a drupal 6 site. I need to spin through an array and set content profile properties using the $key followed by [0]['value'] = $value; I keep getting errors and can't figure out how to create the property dynamically. Here is the code: foreach ($profile_array as $key => $value) { $profile->$key[0]['value'] = $value;} I have tried multiple variations of concatenating $key to [0]['value'] including creating variables and then inserting them in place but nothing is working. Any suggestions on what I can try would be appreciated. Thanks.Dave.
set object property names dynamically
in PHP
Posted · Edited by Dave B.
$profile->{$key}[0]['value'] = $value;
The code above also worked and was more in line with what I was trying to do. I'll look up what the curly braces around the variable do.Thanks to all for their help.Dave.