-1

I did a query in php and all the results are stored in an object. For example

$query = "select * from some_table";
$sth = $dbc->query($query);
$results = $sth->fetchAll();

Therefore the results of the query is stored in $results and I have a property called name. How can I now loop through this object $results to change all the values of a certain property name of the object.

jszobody
  • 27,683
  • 6
  • 59
  • 69
Kern Elliott
  • 1,627
  • 5
  • 37
  • 64

1 Answers1

1

Assuming name is a public property:

for($i = 0; $i < count($results); $i++){
  $results[$i]->name = ...; 
}
Headshota
  • 20,343
  • 11
  • 58
  • 79