i have a var that holds an array of objects. $object:
Array
(
[0] => First_Model Object
(
[_id:protected] => 988198
[_status:protected] => some string here
[_user_id:protected] => 18289
)
[1] => Second_Model Object
(
[_id:protected] => 566198
[_status:protected] => some string here
[_user_id:protected] => 18290
)
....
if i do:
<?php foreach($object as $row): ?>
<?php echo $row->status(); ?>
<?php endforeach: ?>
i get: some string here
what i want to do is to edit $row->status(), maybe use ucwords or something on this string and them place it back in the $object so that when i do the loop i get the changed result.
i could alter the result inside the foreach loop but i want my code to be clean.
so i need to grab $object->status do something with it then place it back on the $object then ill have the modified result..
any ideas on how to place the modified string inside the array of objects?
thanks
foreachloop not clean?array_walk), in future it may work in parallel threads. And I guess php provides some kind of optimalization for calling function via this function (at least callback are called from C source (array_walkis implemented in C), not via interpreted (slower) code).array_walkis almost always slower than justforeach-ing. Future parallel thread? By the time PHP can do that, we'll all have flying cars :)