Update particular contribute based on contribute id with civicrm_api3
You can use civicrm api to process CRUD on CiviCRM Database.

To update contribution you can use

$result = civicrm_api3('Contribution', 'create', [
  'id' =&gt; $contrib_data[0]-&gt;id,
  'contribution_status_id' =&gt; $contribution_status_id,
]);


Cheers

Pradeep