Update items within php objects [duplicate]

I want to update the Content string within the object. With the first foreach I get this:

object(Page)#1716 (20) {
        ["_cache_statusFlags":protected]=> NULL
        ["creatableChildrenCache":protected]=> NULL
        ["destroyed"]=> bool(false)
        ["record":protected]=> array(22) {
          ["ClassName"]=> string(4) "Page"
          ["ID"]=> int(1)
          ["ParentID"]=> int(0)
          ["Title"]=> string(5) "Home"
          ["MenuTitle"]=> NULL
          ["URLSegment"]=> string(4) "home"
          ["Content"]=> string(2210) "
My content that needs to be updated
"...

I tried with json_decode, (array) but I either get “Uncaught Error: Cannot use object of type Page as array” or no error and no update.

// json_decode($results,true);
foreach ($results as $result) {
   json_decode($result,true); // seem like it does nothing
   // tried (array)$result['record']['Content'], (array)$result['Content'],...
   // $result['Content'] = str_replace($keywords,'<span class="highlight-search">' .$keywords . '</span>',$result->Content);
   $result['record']['Content'] = str_replace($keywords,'<span class="highlight-search">' .$keywords . '</span>',$result->Content);
}

I also tried with foreach($result as $key => $field)…

At this point I’m just guessing. What is the proper procedure?