Help referencing object properties
Posted: Thu Apr 05, 2012 7:25 pm
This is kind of a new one for me, how do I fetch a property of an object when the key contains a space?
// Notice the space in 'Panel 1'
Example: $data->design->colors->Panel 1->color;
// Notice the space in 'Panel 1'
Example: $data->design->colors->Panel 1->color;
Code: Select all
<?php
foreach( $data->design->colors as $key => $value ) {
print $key . "\n";
}
?>
/* Output */
Center Flap D
Reserve Handle
Panel 3
Pinstripe D-E
Center Flap B
Cutaway Handle
Center Flap E
Center Flap C
Panel 2
Party Pinstripe B
Party Stripe
Panel 1
Legpad (Out)
Pinstripe C-D
Panel 4
Harness
Backpad
Center Flap A
Pinstripe A-B
Ring Cover
Party Pinstripe A
Pinstripe B-C
Legpad (In)
Main Risers
Binding Tape
Panel 5