View Single Post
Old 11-21-2010, 09:31 AM   PM User | #1
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
Looping through an Object's members and changing its values

Say I have:
PHP Code:
obj.one "Hello, World!"
obj.two "Goodbye, World!"
obj.three "Foo"
obj.four "Bar" 
1. How do I loop through it and change "o" to "a"?
2. Make the changed value permanent (i.e. I changed it by reference)
In PHP you, it's basically this:
PHP Code:
$v = (object)array('one' => "foooo"'two' => "bo");
for( 
$v => &$val ) {
$val str_replace('o'$val);


Last edited by Apothem; 11-21-2010 at 09:33 AM..
Apothem is offline   Reply With Quote